先日Contractを作りましたが、contractオブジェクトはgethを停止すると消えます。
なので再度起動した場合もう一度呼び出してあげる必要があります。
呼び出すには対象のコントラクト以下2つの情報が必要です。
・Application Binary Interface (ABI)
・address
先日私の作ったhellowEthereumだと
・Application Binary Interface [{ constant: true, inputs: [], name: "get", outputs: [{ name: "retVal", type: "string" }], type: "function" }, { constant: true, inputs: [], name: "getCnt", outputs: [{ name: "retVal", type: "uint256" }], type: "function" }] ・address 0x2d37e8d3c1941039dabf06f7db30d5713132615f
ABIもメモしておかないと駄目なんですね。
アドレスがわかれば 「eth.getCode('0x2d37e8d3c1941039dabf06f7db30d5713132615f')」
とかでコードは取ってこれるで、そこからABIも導けるとおもっていたのですがそうはなっていない模様。
なので、これをまた改行をとって埋め込む必要があります。このあたりなんとかならんのかな。
cnt = eth.contract([{ constant: true, inputs: [], name: "get", outputs: [{ name: "retVal", type: "string" }], type: "function"}, { constant: true, inputs: [], name: "getCnt", outputs: [{ name: "retVal", type: "uint256" }], type: "function"}]).at('0x2d37e8d3c1941039dabf06f7db30d5713132615f'); { _eth: { _requestManager: { polls: {}, provider: { send: function(), sendAsync: function() }, timeout: null, poll: function(), reset: function(keepIsSyncing), send: function(data), sendAsync: function(data, callback), sendBatch: function(data, callback), setProvider: function(p), startPolling: function(data, pollId, callback, uninstall), stopPolling: function(pollId) }, accounts: ["0x11b00fff3570ac74d66192ffc18d3621b0b3dc4e", "0xcf573ec35da6c35ded1a5416461de11bec0c89c0", "0x851cc0735985613418397b6a409e456393d2653e"], blockNumber: 53, coinbase: "0x11b00fff3570ac74d66192ffc18d3621b0b3dc4e", compile: { lll: function(), serpent: function(), solidity: function() }, defaultAccount: undefined, defaultBlock: "latest", gasPrice: 50000000000, hashrate: 0, mining: false, pendingTransactions: null, syncing: false, call: function(), contract: function(abi), estimateGas: function(), filter: function(fil, callback), getAccounts: function(callback), getBalance: function(), getBlock: function(), getBlockNumber: function(callback), getBlockTransactionCount: function(), getBlockUncleCount: function(), getCode: function(), getCoinbase: function(callback), getCompilers: function(), getGasPrice: function(callback), getHashrate: function(callback), getMining: function(callback), getNatSpec: function(), getPendingTransactions: function(callback), getStorageAt: function(), getSyncing: function(callback), getTransaction: function(), getTransactionCount: function(), getTransactionFromBlock: function(), getTransactionReceipt: function(), getUncle: function(), getWork: function(), iban: function(iban), icapNamereg: function(), isSyncing: function(callback), namereg: function(), resend: function(), sendIBANTransaction: function(), sendRawTransaction: function(), sendTransaction: function(), sign: function(), signTransaction: function(), submitTransaction: function(), submitWork: function() }, abi: [{ constant: true, inputs: [], name: "get", outputs: [{...}], type: "function" }, { constant: true, inputs: [], name: "getCnt", outputs: [{...}], type: "function" }], address: "0x2d37e8d3c1941039dabf06f7db30d5713132615f", transactionHash: null, allEvents: function(), get: function(), getCnt: function() } >
出てきました!
> cnt.get() "Hello World!!" > cnt.getCnt function() > cnt.getCnt() 1 >
昨日のままですね。