Solidity
Solidity 0.6及以上版本如何充值到WETH?
Solidity 0.6.0對ETH 轉賬的執行方式進行了重大更改。以下不再起作用:
weth.deposit.value(amount)();
將 ETH 存入WETH合約的最新語法是什麼?
堅固度 0.6 和 0.7
pragma solidity >=0.6.0; interface WethLike { function deposit() external payable; function withdraw(uint256) external; } contract MyContract { WethLike weth; constructor(WethLike weth_) { weth = weth_; } function foo() external payable { weth.deposit{ value: msg.value }(); } }