Contract-Development
Coin 是保留字嗎?
如果我嘗試在 Mix 中編譯以下範常式式碼,它將不起作用。一旦我將名稱從 Coin 更改為 Coins,它就會開始按預期工作?這是錯誤還是功能?
contract Coin { // The keyword "public" makes those variables // readable from outside. address public minter; mapping (address => uint) public balances; // Events allow light clients to react on // changes efficiently. event Sent(address from, address to, uint amount); // This is the constructor whose code is // run only when the contract is created. function Coin() { minter = msg.sender; } function mint(address receiver, uint amount) { if (msg.sender != minter) return; balances[receiver] += amount; } function send(address receiver, uint amount) { if (balances[msg.sender] < amount) return; balances[msg.sender] -= amount; balances[receiver] += amount; Sent(msg.sender, receiver, amount); } }
該
Coin
合約包含在Solidity 標準庫中——這是概念證明時代的一項功能。標準庫包括以下合約:
Config
,Coin
,CoinReg
,coin
,service
,owned
,mortal
,NameReg
,named
,std
,configUser
.目前不鼓勵使用它們,除了
owned
和mortal
。