Solidity 错误处理,require()
demo.sol(错误处理,require()):
pragma solidity ^0.4.21;
contract HasAnOwner {
address public owner;
uint public a;
constructor() public {
owner = msg.sender;
}
function useSuperPowers() public {
require(msg.sender == owner); // 条件不满足会抛异常。
/*
if (msg.sender != owner){ // 该方式已过时。
throw; // 抛异常。
}
*/
a = 10;
}
}