账户
0x70...3c38
0x70...3C38

0x70...3C38

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.9+commit.e5eed63a
语言
Solidity
合同源代码
文件 1 的 1:EIP1559Burn.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.9;

interface IERC20 {
    function withdraw(uint256 amount) external payable;
    function transfer(address to, uint256 value) external returns (bool);
    function balanceOf(address who) external view returns (uint256);
}

interface IERC20Predicate {
    function startExitWithBurntTokens(bytes calldata data) external;
}

interface IWithdrawManager {
    function processExits(address _token) external;
}

contract EIP1559Burn {
    IERC20 public immutable maticRootToken;
    IERC20 public immutable maticChildToken = IERC20(0x0000000000000000000000000000000000001010);
    IWithdrawManager public immutable withdrawManager;
    uint24 public immutable rootChainId;
    uint24 public immutable childChainId;

    constructor(
        IERC20 _maticRootToken,
        IWithdrawManager _withdrawManager,
        uint24 _rootChainId,
        uint24 _childChainId
        ) {
        maticRootToken = _maticRootToken;
        withdrawManager = _withdrawManager;
        rootChainId = _rootChainId;
        childChainId = _childChainId;
    }

    modifier onlyRootChain() {
        require(block.chainid == rootChainId, "ONLY_ROOT");
        _;
    }

    modifier onlyChildChain() {
        require(block.chainid == childChainId, "ONLY_CHILD");
        _;
    }

    receive() external payable {

    }

    function withdraw() external onlyChildChain payable {
        maticChildToken.withdraw{value: address(this).balance}(address(this).balance);
    }

    function initiateExit(IERC20Predicate _erc20Predicate, bytes calldata data) external onlyRootChain {
        _erc20Predicate.startExitWithBurntTokens(data);
    }

    function exit() external onlyRootChain {
        require(gasleft() > 370000, "MORE_GAS_NEEDED"); // WithdrawManager needs 300k, 65k for ERC20 transfer + leeway
        withdrawManager.processExits(address(maticRootToken));
        uint256 tokenBalance = maticRootToken.balanceOf(address(this));
        if (tokenBalance > 0) {
            maticRootToken.transfer(0x000000000000000000000000000000000000dEaD, tokenBalance);
        }
    }
}
设置
{
  "compilationTarget": {
    "contracts/EIP1559Burn.sol": "EIP1559Burn"
  },
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 9999
  },
  "remappings": []
}
ABI
[{"inputs":[{"internalType":"contract IERC20","name":"_maticRootToken","type":"address"},{"internalType":"contract IWithdrawManager","name":"_withdrawManager","type":"address"},{"internalType":"uint24","name":"_rootChainId","type":"uint24"},{"internalType":"uint24","name":"_childChainId","type":"uint24"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"childChainId","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Predicate","name":"_erc20Predicate","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initiateExit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maticChildToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maticRootToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rootChainId","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawManager","outputs":[{"internalType":"contract IWithdrawManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]