Skip to content

Instantly share code, notes, and snippets.

@blueplanet
Last active December 6, 2017 22:37
Show Gist options
  • Save blueplanet/1f8ce3a571eb7304db728408b78ee488 to your computer and use it in GitHub Desktop.
Save blueplanet/1f8ce3a571eb7304db728408b78ee488 to your computer and use it in GitHub Desktop.
コントラクトの関数を呼び出す際起こったこと ref: https://qiita.com/blueplanet/items/af9dd28d81b4c238ad30
contract SingleNumRegister {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
contract SingleNumRegister {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
[{
constant: false,
inputs: [{name: 'x', type: 'uint256'}],
name: 'set',
outputs: [ ],
type: 'function'
}, {
constant: true,
inputs: [ ],
name: 'get',
outputs: [{name: 'retVal', type: 'uint256'} ],
type: 'function'
} ]
[{
constant: false,
inputs: [{name: 'x', type: 'uint256'}],
name: 'set',
outputs: [ ],
type: 'function'
}, {
constant: true,
inputs: [ ],
name: 'get',
outputs: [{name: 'retVal', type: 'uint256'} ],
type: 'function'
} ]
// ABI_DEF:上記どおり、コントラクトをコンパイルした時できたコントラクトの定義情報
// ADDRESS:コントラクトアカウトのアドレス
var cnt = eth.contract(ABI_DEF).at(ADDRESS);
// 書き込み
cnt.set.sendTransaction(6,{from:eth.accounts[0]})
// トランザクションIDが返される '0x979c4e413a647673632d74a6c8b7f5b25a3260f3fefa4abea2dc265d61215939'
// マイニングし、上記トランザクションがブロックチェーンに書き込まれるまで待つ必要がある
cnt.get()
// '6'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment