欢迎订阅专栏:3分钟Solidity--智能合约--Web3区块链技术必学
如需获取本内容的最新版本,请参见 Cyfrin.io 上的汇编错误(代码示例)
汇编错误的示例
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract AssemblyError {
function yul_revert(uint256 x) public pure {
assembly {
// revert(p, s) - end execution
// revert state changes
// return data mem[p…(p+s))
if gt(x, 10) { revert(0, 0) }
}
}
}
Remix Lite 尝试一下
END