I am calling a method in smart contract, which transfers tokens from sender account to holder account. the transferFrom is failing with error

MetaMask - RPC Error: Error: Error: [ethjs-rpc] rpc error with payload {"id":3714284134436,"jsonrpc":"2.0","params":["0xf88f108502540be400832191c09459d3631c86bbe35ef041872d502f218a39fba15080a47547c7a300000000000000000000000000000000000000000000000000000000000000018602c909e5519ba010b173df9bdb6747b6cdf6dd8f50513d0582c67d8689aaadb9645dcc8c3bcd34a020da92f1f07c57979bf1deee5dd80c7418eda23950bdc089223f1a647101bb64"],"method":"eth_sendRawTransaction"} Error: VM Exception while processing transaction: revert {code: -32603, message: "Error: Error: [ethjs-rpc] rpc error with payload {…VM Exception while processing transaction: revert"}

enter image description here


function getTokens (uint _level) public onlyUnlocked {
require (token.transferFrom(msg.sender, tokenAddress, reward.stakedAmount));
//require (token.transferFrom(msg.sender, address(this), reward.Amount));    }

Any suggestions please how to fix or debug issue

  • 1
    Did the account with the tokens approve the contract first? – smarx Jul 10 at 18:55
  • If that's not it, you'll probably need to share the smart contract code. – smarx Jul 10 at 18:56
  • I actually tried approve, but it didnt work. I have an UI, from UI, i called the token.approve() in token contract Then I am calling the getTokens() in another contract(code pasted above). Is there anything wrong I am doing? – gggg Jul 10 at 19:11
  • I imagine that onlyUnlocked does a require. That means you have two require statements, and one of them is causing the revert. Remove one and see what happens to figure out which it is. Then continue debugging. (If it's onlyUnlocked, look at that code. If it's token.transferFrom, double check what token is and how tokenFrom is implemented. Check that the allowance for msg.sender is at least reward.stakedAmount.) – smarx Jul 10 at 19:19
  • And generally the sender needs to approve on the ERC20 Token and then the receiver can call transferFrom on the same Token afterwards. The sender approves the transfer to the receiver before the receiver “withdraws” from the sender. – schemar Jul 10 at 20:12

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.