solidity基础-异常
assert
contract ErrorTest { uint256 public balance; function deposit(uint256 _amount) public{ balance = balance + _amount; } function withdraw(uint256 _amount) public{ uint256 oldBalance = balance; balance = balance - _amount; assert(balance > oldBalance ); } }
部署存入25, 可以看到balance 有 25
再提取 100
输出报错