I have tried this solution and it worked but only if I use privateKey of the wallet which I used to create custom tokens but what if I want to send from B wallet to C wallet and when I am trying it, the transaction is happening but it's failing.

Failed transaction

var contract = new ethers.Contract(contractAddress, abi, wallet);

var numberOfTokens = ethers.utils.parseUnits('10.0',numberOfDecimals);
var options = { gasLimit: 1500000, gasPrice: ethers.utils.parseUnits('1.0', 'gwei') };

contract.transferFrom(fromAddress, targetAddress,numberOfTokens,options).then(function (tx) { console.log(tx); });


  • 2
    Has the token owner added an approve for the tokens? They can't be transferred without his consent. Mar 20, 2019 at 13:08
  • 1
    i am the owner but how to approve the transfer?
    – iamsujit
    Mar 20, 2019 at 17:17

1 Answer 1


For this to work, you have to call an approve function of the ERC20 token smart contract that you want to transfer. You have to pass the amount that you want to transfer and the spender address to the approve function. Only then you will be able to make the actual transfer.

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.