编译器
0.8.17+commit.8df45f5f
文件 1 的 2:BTCBridge.sol
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract BTCBridge {
address public beneficiary;
event Deposit(address initiator, address token, uint amount, string out_chain, string out_address);
constructor(address _beneficiary) {
beneficiary = _beneficiary;
}
function depositETH(string memory out_chain, string memory out_address) public payable {
payable(beneficiary).transfer(msg.value);
emit Deposit(msg.sender, address(0), msg.value, out_chain, out_address);
}
function depositERC20(address token, uint amount, string memory out_chain, string memory out_address) public {
IERC20(token).transferFrom(msg.sender, beneficiary, amount);
emit Deposit(msg.sender, token, amount, out_chain, out_address);
}
}
文件 2 的 2:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from,
address to,
uint256 amount
) external returns (bool);
}
{
"compilationTarget": {
"contracts/BTCBridge.sol": "BTCBridge"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"out_chain","type":"string"},{"indexed":false,"internalType":"string","name":"out_address","type":"string"}],"name":"Deposit","type":"event"},{"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"out_chain","type":"string"},{"internalType":"string","name":"out_address","type":"string"}],"name":"depositERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"out_chain","type":"string"},{"internalType":"string","name":"out_address","type":"string"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"}]