2017年8月31日 星期四

learn truffle and solidity - pet shop - note

* Public variables have automatic getter methods
* array getters return only a single value from a given key
* this, a contract-wide variable that gets the current contract's address
* Since the array contains address types, Ethereum initializes the array with 16 empty addresses

* Types
int: –2147483648 to 2147483647
uint: 0 to 4294967295
http://solidity.readthedocs.io/en/develop/types.html


```
mapping (address => uint) public balances;
```
=>
```
function balances(address _account) returns (uint) {
    return balances[_account];
}
```

* 跟 contract 一樣名稱的 function 就是 constructor




http://truffleframework.com/tutorials/pet-shop

沒有留言:

張貼留言