I am working on a migration contract and the flow is as follows:

Contract function calculates balance of XXX coin -> Contract sends amount XXX of OLD token to burn address -> Contract sends xxx of new token to msg.sender

I am having issues with the middle part and the transferFrom() call is giving me the below error:

transact to DeadTokenMigration.migrate errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

I realize this is quite a common error, but I cannot figure out which account is actually at fault here

Here is the code of the function:

 function migrate() public virtual{

// gets Dead CoinBalance for a user.
XXXBalance = DeadToken(CoinToBeConverted).balanceOf(_msgSender());

//For TRansparency, old coins are sent to the Burn Address
require(XXXXBalance > 0, "Balance too small to migrate!");
DeadToken(CoinToBeConverted).transferFrom(_msgSender(), address(0), XXXXBalance);

// Transfer from RCVR Migration contract to msg.sender

} }

The First and last functions work so getting the balance and transferring the new tokens across

Any help would be amazing!

1 Answer 1


In order to use transferFrom(), you first need to call approve(). You can read about it here, but basically you need to give the contract permission to send the tokens on your behalf.

The approve() must be performed in a different transaction before this one.

  • Thank you so much, ive just tried now and thats worked. I really appreciate the time youve taken to help me out!
    – Joe_Bloggs
    Commented Nov 5, 2020 at 13:33

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.