Last active
December 6, 2017 22:37
-
-
Save blueplanet/1f8ce3a571eb7304db728408b78ee488 to your computer and use it in GitHub Desktop.
コントラクトの関数を呼び出す際起こったこと ref: https://qiita.com/blueplanet/items/af9dd28d81b4c238ad30
This file contains hidden or 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
contract SingleNumRegister { | |
uint storedData; | |
function set(uint x) { | |
storedData = x; | |
} | |
function get() constant returns (uint retVal) { | |
return storedData; | |
} | |
} |
This file contains hidden or 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
contract SingleNumRegister { | |
uint storedData; | |
function set(uint x) { | |
storedData = x; | |
} | |
function get() constant returns (uint retVal) { | |
return storedData; | |
} | |
} |
This file contains hidden or 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
[{ | |
constant: false, | |
inputs: [{name: 'x', type: 'uint256'}], | |
name: 'set', | |
outputs: [ ], | |
type: 'function' | |
}, { | |
constant: true, | |
inputs: [ ], | |
name: 'get', | |
outputs: [{name: 'retVal', type: 'uint256'} ], | |
type: 'function' | |
} ] |
This file contains hidden or 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
[{ | |
constant: false, | |
inputs: [{name: 'x', type: 'uint256'}], | |
name: 'set', | |
outputs: [ ], | |
type: 'function' | |
}, { | |
constant: true, | |
inputs: [ ], | |
name: 'get', | |
outputs: [{name: 'retVal', type: 'uint256'} ], | |
type: 'function' | |
} ] |
This file contains hidden or 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
// 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