合同代码
pragma solidity ^0.4.6;
contract SimpleStorage{
uint storedData;
function set(uint x){
storedData=x;
}
function get() constant returns(uint retVal){
return storedData;
}
}
部署合同
haha@ubuntu:~/trufflecode$ truffle compile
Compiling SimpleStorage.sol...
Writing artifacts to ./build/contracts
haha@ubuntu:~/trufflecode$ truffle migrate
Running migration: 1_initial_migration.js
Deploying SimpleStorage...
SimpleStorage: 0xbcba93b7c51a42e4b4d9ff498f64272338715e80
Saving successful migration to network...
Saving artifacts...
geth端会输出
I1215 17:22:45.321097 internal/ethapi/api.go:940] Tx(0xfd6a8480a0e819c7e15599da2cbdb19f510c639434a499ca7cc0a40ef8156ae3) created: 0x40d76916b1782b70f5b922719ca4f779a7b2b1eb
查询合同部署在哪个区块
>eth.getTransaction('0xfd6a8480a0e819c7e15599da2cbdb19f510c639434a499ca7cc0a40ef8156ae3')
{
blockHash: "0x1bfe4bc92817d44843d03712351d2e6b4d79629f8f6bc41bef944d6c3c632e1d",
blockNumber: 8035,
from: "0x414d9703aa1c26115dc2cdabe225db3bedc7a91f",
gas: 4712388,
gasPrice: 100000000000,
hash: "0xfd6a8480a0e819c7e15599da2cbdb19f510c639434a499ca7cc0a40ef8156ae3",
input: "0x6060604052346000575b6061806100166000396000f3606060405260e060020a600035046360fe47b1811460265780636d4ce63c146035575b6000565b3460005760336004356051565b005b34600057603f605a565b60408051918252519081900360200190f35b60008190555b50565b6000545b9056",
nonce: 12,
r: "0x1565976644674d077973e15ebbbfd9816aa16534ec572f71d0ffe5954f6976d1",
s: "0x6d93f9f0ba07651db19d220fcaa445a8932cbc2a95bc5887211b137ba67713f4",
to: null,
transactionIndex: 0,
v: "0x1c",
value: 0
}
simple = eth.contract(abi).at('0x40d76916b1782b70f5b922719ca4f779a7b2beb')