1

Here's the error:

index.js:1 Error: Returned error: unknown account

I'm getting this error while running this method:


nftMintingContract.methods.mint(account, cid).send({from: account})

The expected behaviour for this is to have metamask opening and requiring you to sign the transaction, but instead, I get this error from the browser console.

I can't wrap my head around why this might be, I've been running other methods with the exact same syntax which have been running properly. notice the .send({from:account}):

lpContract.methods
    .approve(address, ethers.constants.MaxUint256)
    .send({ from: account })

masterChefContract.methods
    .deposit(pid, new BigNumber(amount).times(new BigNumber(10).pow(18)).toString())
    .send({ from: account })

#and so on...

I've done some research and I've found people saying that you have to import the wallet with the private key and so on, but this cannot be the case since I've been running methods with .send({from: account}) which have been launching metamask instead and asking you to sign the transaction.

I'm fairly new to this, so any help would be kindly appreciated. Thanks!

5
  • Hi there! You shouldn't need to import a private key, but do need to import MetaMask - could you include the code where you set account?
    – Linum Labs
    Commented Jul 25, 2021 at 7:56
  • import { useWallet } from '@binance-chain/bsc-use-wallet' const { account }: { account: string } = useWallet() This outputs a string with the current connected wallet Commented Jul 25, 2021 at 8:37
  • 1
    This appears to be more of a question about how to connect to MetaMask using bsc-use-wallet. bsc-use-wallet is a fork of Aragon's use-wallet, which in turn makes use of web3react. Understanding web3react would be very useful in understanding how to connect MetaMask to your code. Are you using a React codebase?
    – Linum Labs
    Commented Jul 25, 2021 at 8:58
  • @LinumLabs yes sir, it's a react project. In fact, it is a fork of the pancakeswap frontend (github.com/pancakeswap/pancake-frontend). I have been replicating the way they use these methods correctly, and already added a few more functionalities with our custom solidity contracts. It's the first time I encounter this error. Commented Jul 25, 2021 at 10:01
  • have you solve this? im having the same problem
    – John
    Commented Nov 11, 2021 at 10:37

1 Answer 1

0

You have to use Metamask provider instead of node URL const web3 = new Web3(window.ethereum);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.