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
    Jul 25 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 Jul 25 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
    Jul 25 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. Jul 25 at 10:01
  • have you solve this? im having the same problem
    – John
    Nov 11 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.