账户
0x80...1e2f
0x80...1e2f

0x80...1e2f

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.22+commit.4fc1097e
语言
Solidity
合同源代码
文件 1 的 1:Splitter.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2 <0.9.0;


interface ERC20 {
    function transfer(address to, uint amount) external returns(bool);
    function balanceOf(address a) external returns(uint256);
}


contract Splitter {
    address immutable public a;
    address immutable public b;

    constructor(address _a, address _b) {
        a = _a;
        b = _b;
    }

    // callable by anyone
    function split(ERC20 token, uint amount) public {
        if(amount == 0) {
            amount = token.balanceOf(address(this));
        }

        // round down. leftovers will stay in the contract
        uint half = amount / 2;

        // if token is not standard and does not return true upon success, then sfyl.
        require(token.transfer(a, half));
        require(token.transfer(b, half));        
    }

}
设置
{
  "compilationTarget": {
    "Splitter.sol": "Splitter"
  },
  "evmVersion": "shanghai",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[{"internalType":"address","name":"_a","type":"address"},{"internalType":"address","name":"_b","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"a","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"b","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"split","outputs":[],"stateMutability":"nonpayable","type":"function"}]