/**
*Submitted for verification at Etherscan.io on 2021-08-25
*/
/**
*Submitted for verification at Etherscan.io on 2021-08-10
*/
// SPDX-License-Identifier: none
pragma solidity ^0.8.4;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount)
external
returns (bool);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
interface IToken {
function mint(address to, uint256 amount) external;
function burn(address owner, uint256 amount) external;
function changeOwnership(address _newOwner) external;
}
contract MigrationETH {
address public admin;
IToken public token;
IERC20 public token_;
uint256 public nonce;
address public feepayer;
mapping(uint256 => bool) public processedNonces;
address fromAddr = address(this);
enum Step {
TransferTo,
TransferFrom
}
event Transfer(
address from,
address to,
uint256 amount,
uint256 date,
uint256 nonce,
Step indexed step
);
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor(address _token) {
admin = msg.sender;
token = IToken(_token);
token_ = IERC20(_token);
}
// transfer Ownership to other address
function transferOwnership(address _newOwner) public {
require(_newOwner != address(0x0));
require(msg.sender == admin);
emit OwnershipTransferred(admin, _newOwner);
admin = _newOwner;
}
// transfer Ownership to other address
function transferTokenOwnership(address _newOwner) public {
require(_newOwner != address(0x0));
require(msg.sender == admin);
token.changeOwnership(_newOwner);
}
function transferFromContract(
address to,
uint256 amount,
uint256 otherChainNonce
) external {
require(msg.sender == admin, "only admin");
require(
processedNonces[otherChainNonce] == false,
"transfer already processed"
);
processedNonces[otherChainNonce] = true;
token_.transfer(to, amount);
emit Transfer(
msg.sender,
to,
amount,
block.timestamp,
otherChainNonce,
Step.TransferFrom
);
}
}
{
"compilationTarget": {
"MigrationETH.sol": "MigrationETH"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"date","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"enum MigrationETH.Step","name":"step","type":"uint8"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feepayer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"processedNonces","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token_","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"otherChainNonce","type":"uint256"}],"name":"transferFromContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferTokenOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]