This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ export HOME="ご自分のホームディレクトリ" | |
$ cd $HOME/work/bitcoin | |
$ mkdir -p db4 | |
$ cd db4 | |
$ wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' | |
$ tar -xzvf db-4.8.30.NC.tar.gz | |
$ cd db-4.8.30.NC/build_unix/ | |
$ ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$HOME/work/bitcoin/db4/ | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumber() public returns (uint) { | |
uint a = 3; | |
uint b = 6; | |
uint c = a * b; // 18を返す | |
uint d = b / a * 10; // 余りの1は無視され、20を返す | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getString() returns (string) { | |
string a = "ethereum"; | |
string b = "solidity"; | |
} | |
// 文字列比較の際は、一度、ハッシュ化を行う必要がある | |
function compStr(string _str) pure returns (bool) { | |
return (keccak256(_str) == keccak256("hoge")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBool() public returns (bool) { | |
bool a = true; | |
bool b = false; | |
// このとき既にbがfalseであるため、aの処理は発動されない | |
if (b || a) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getArray() public returns (uint[]) { | |
uint[2] a; // 固定長配列の宣言 | |
uint[] b; // 可変長配列の宣言 | |
b.push(1); // 要素の追加はpushを使う | |
uint length = b.length; // 配列の要素数はlengthで取得する | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct a { | |
uint8 b; // このとき可能な限りbit数を下げることで、容量を下げ、使用するGASの節約に繋がる | |
string c; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBalance(address _addr) returns (uint) { | |
return _addr.balance; // 残高を返す | |
} | |
function send(address _to, uint _amount) { | |
_to.send(_amount); // Etherの送金 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct User { | |
string name; | |
uint8 age; | |
} | |
mapping (address => balance) balanceList; | |
mapping (address => User) userList; | |
function setBalance(address _address) { | |
balanceList[_address] = _address.balance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ether() { | |
uint wei = 1 wei; | |
uint szabo = 1 szabo; | |
uint finney = 1 finney; | |
uint ether = 1 ether; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function time() { | |
uint seconds = 1 seconds; | |
uint minutes = 1 minutes; | |
uint hours = 1 hours; | |
uint days = 1 days; | |
uint weeks = 1 weeks; | |
uint years = 1 years; | |
} |