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
XXXX(XXXXAddress).transfer(_msgSender(),XXXXBalance);
} }
The First and last functions work so getting the balance and transferring the new tokens across
Any help would be amazing!