I’m actually working to a smart contract where I migrate an old token to a new token :
First I need to mint with conversion 1:1 and then burn the old token.
I start with this contract but I’m not sure about it :
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import Token from "../Token.sol";
contract MigrationToken {
// Old Token
address public tokenV1;
// New Token
address public tokenv2;
uint256 public endBlock;
constructor(
address _tokenV1,
address _tokenV2,
uint256 _endBlock
) public {
tokenV1 = _tokenV1;
tokenv2 = _tokenV2;
endBlock = _endBlock;
}
event MigrateToV2(address indexed user,uint256 amount);
function migratationNewToken(uint256 _inputAmt) public {
require(block.number < endBlock, "too late :(");
IERC20(tokenV1).safeTransferFrom(
address(msg.sender),
burnAddress,
_inputAmt
);
Token(tokenv2).mint(msg.sender, _inputAmt);
emit MigrateToV2(msg.sender,_inputAmt);
}
}