软件环境
go:1.9.2
ethereum&GETH:v1.8.11-unstable
编译
> solc -o . --bin --abi vote.sol
会生成两类文件,*.abi *.bin
vote.sol 里面包含了 library和多个contract 类,我这里吧AidocVote.abi、AidocVote.bin 上链
编辑AidocVote.abi文件
var VoteContract = eth.contract([{"constant":false,"inputs":[{"name":"_miner","type":"address"},{"name":"_vote","type":"uint256"}],"name":"makeVote","outputs":[{"name":"retVal","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"getMinerInfo","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"minerMapping","outputs":[{"name":"voteNumber","type":"uint256"},{"name":"flag","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"payeeAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"voteMapping","outputs":[{"name":"voteAddress","type":"address"},{"name":"voteNumber","type":"uint256"},{"name":"aidoc","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_key","type":"uint256"}],"name":"getMinerAddress","outputs":[{"name":"retVal","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"payee","type":"address"}],"name":"switchPayee","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"test2","outputs":[{"name":"retAddress","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"miner","type":"address"}],"name":"isMiner","outputs":[{"name":"retVal","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"addMiner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"minerArr","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMinerCount","outputs":[{"name":"minerCount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"getVoteInfo","outputs":[{"name":"voteAddress","type":"address"},{"name":"voteNumber","type":"uint256"},{"name":"aidoc","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"test","outputs":[{"name":"retBool","type":"bool"},{"name":"retAddress","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"voteAddress","type":"address"},{"indexed":false,"name":"voteNumber","type":"uint256"},{"indexed":false,"name":"aidoc","type":"uint256"}],"name":"WithdrawCoin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}])
编辑AidocVote.bin文件
personal.unlockAccount(eth.accounts[0])
var vote = VoteContract.new({
from: eth.accounts[0],
data: "0x608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073dca980c19d4b3782e7a21496f6b260432854d1e7600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061132a806100b66000396000f3006080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b187ab3146104615780630b34d553146104c65780631670a64a1461051d57806333cede131461057f5780634ffb203e146105d65780635e8885fb1461066757806360f292b5146106d457806366e41cb71461072f578063701b70ac14610786578063819f163a146107e15780638da5cb5b14610810578063a529794714610867578063bb52c137146108d4578063dc1e30da146108ff578063f2fde38b14610990578063f8a8fd6d146109d3575b6000803391503490506000811115156100fe57600080fd5b336000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101c96000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506102596000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610306573d6000803e3d6000fd5b507f7c6e301a3fc56528ab958cb48a309593cdca31df786612efd37ceb10e9aa86ae6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020154604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a15050005b34801561046d57600080fd5b506104ac600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a53565b604051808215151515815260200191505060405180910390f35b3480156104d257600080fd5b50610507600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bd1565b6040518082815260200191505060405180910390f35b34801561052957600080fd5b5061055e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c1d565b60405180838152602001821515151581526020019250505060405180910390f35b34801561058b57600080fd5b50610594610c4e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105e257600080fd5b50610617600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c74565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561067357600080fd5b5061069260048036038101908080359060200190929190505050610cbe565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106e057600080fd5b50610715600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d01565b604051808215151515815260200191505060405180910390f35b34801561073b57600080fd5b50610744610e42565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561079257600080fd5b506107c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e4a565b604051808215151515815260200191505060405180910390f35b3480156107ed57600080fd5b506107f6610ea3565b604051808215151515815260200191505060405180910390f35b34801561081c57600080fd5b50610825611015565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561087357600080fd5b506108926004803603810190808035906020019092919050505061103b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108e057600080fd5b506108e9611079565b6040518082815260200191505060405180910390f35b34801561090b57600080fd5b50610940600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611086565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561099c57600080fd5b506109d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061117e565b005b3480156109df57600080fd5b506109e86112d6565b60405180831515151581526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b6000808284019050838110151515610a4957fe5b8091505092915050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015410151515610aa557600080fd5b610af06000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154836112e5565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550610b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015483610a35565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055506001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001549050919050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16905082565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b6000600282815481101515610ccf57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d5f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610d9b57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610df857600080fd5b81600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600033905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff169050919050565b6000801515600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff161515141515610f0657600080fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548160ff02191690831515021790555060023390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028181548110151561104a57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600280549050905090565b60008060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549250925092509193909250565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111da57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561121657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060016000915091509091565b60008282111515156112f357fe5b8183039050929150505600a165627a7a7230582055c8f329f5744e02e0f7dd32cd6fed99bc45d7d57a535c54e1c21373ac328be70029",
gas: 500000
})
注意data 添加0x
前缀否则会报错
启动私链
/opt/gopath/src/github.com/ethereum/go-ethereum/build/bin/geth attach /Users/zhangyueru/datadir/node32/node32.ipc
部署
> loadScript("AidocVote.abi")
true
> loadScript("AidocVote.bin")
Unlock account 0xf5d4331b11f119c36cfcc85effe0d3f3fec4a099
Passphrase:
true
在本地已经上链成功,来看下pending交易池
> txpool
{
content: {
pending: {
0xF5d4331B11F119c36cfcc85eFFE0d3F3FEc4A099: {
2: {...}
}
},
queued: {}
},
inspect: {
pending: {
0xF5d4331B11F119c36cfcc85eFFE0d3F3FEc4A099: {
2: "contract creation: 0 wei + 500000 gas × 18000000000 wei"
}
},
queued: {}
},
status: {
pending: 1,
queued: 0
},
getContent: function(callback),
getInspect: function(callback),
getStatus: function(callback)
}
>
我们启动挖矿就可以把此交易同步到其他节点
启动挖矿
> miner.start()
null
停止挖矿
> miner.stop()
true
查看pending池
> txpool
{
content: {
pending: {},
queued: {}
},
inspect: {
pending: {},
queued: {}
},
status: {
pending: 0,
queued: 0
},
getContent: function(callback),
getInspect: function(callback),
getStatus: function(callback)
}
我们来查看下本次的智能合约地址和txid交易记录
> vote
{
abi: [{
constant: false,
inputs: [{...}, {...}],
name: "makeVote",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getMinerInfo",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "minerMapping",
outputs: [{...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [],
name: "payeeAddress",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "voteMapping",
outputs: [{...}, {...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getMinerAddress",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [{...}],
name: "switchPayee",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "test2",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "isMiner",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [],
name: "addMiner",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "owner",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "minerArr",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [],
name: "getMinerCount",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getVoteInfo",
outputs: [{...}, {...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [{...}],
name: "transferOwnership",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "test",
outputs: [{...}, {...}],
payable: false,
stateMutability: "pure",
type: "function"
}, {
inputs: [],
payable: false,
stateMutability: "nonpayable",
type: "constructor"
}, {
payable: true,
stateMutability: "payable",
type: "fallback"
}, {
anonymous: false,
inputs: [{...}, {...}, {...}],
name: "WithdrawCoin",
type: "event"
}, {
anonymous: false,
inputs: [{...}, {...}],
name: "OwnershipTransferred",
type: "event"
}],
address: undefined,
transactionHash: "0x88e310542474d084c40588d0e899a7d81cc3a98c633ddeb9a60cac0c04324fc4"
}
>
address
是智能合约地址,transactionHash
交易hans,发现address
是undefined,没关系我们来排查下
> eth.getTransactionReceipt("0x88e310542474d084c40588d0e899a7d81cc3a98c633ddeb9a60cac0c04324fc4")
{
blockHash: "0x4a5f1979fbafcff62be06459b965da27709b16fbcaf0e78ce76136bf3266fec1",
blockNumber: 20,
contractAddress: "0x0dce68751109c17bb6884b125cdd9efb52587e84",
cumulativeGasUsed: 500000,
from: "0xf5d4331b11f119c36cfcc85effe0d3f3fec4a099",
gasUsed: 500000,
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
root: "0xb64c13776b053d182f8d85d8fe955baaec31061018d7e5b9fb5b107e5dbe177d",
to: null,
transactionHash: "0x88e310542474d084c40588d0e899a7d81cc3a98c633ddeb9a60cac0c04324fc4",
transactionIndex: 0
}
cumulativeGasUsed和gasUsed明显已经消耗完我们 AidocVote.bin
中 contract.new()
交易的gas
的设置,应该加大gas
的消耗
web3.eth.getTransactionReceipt
web3.eth.getTransactionReceipt()方法返回指定交易的收据对象。 如果交易处于pending状态,则返回null。
调用:
web3.eth.getTransactionReceipt(hash [, callback])
参数:
hash:String - 交易的哈希值
callback:Function - 可选的回调函数,其第一个参数为错误对象,第二个参数为结果
返回值:
一个Promise对象,其解析值为交易的收据对象或者null。收据对象具有如下字段:
status - Boolean: 成功的交易返回true,如果EVM回滚了该交易则返回false
blockHash 32 Bytes - String: 交易所在块的哈希值
blockNumber - Number: 交易所在块的编号
transactionHash 32 Bytes - String: 交易的哈希值
transactionIndex - Number: 交易在块中的索引位置
from - String: 交易发送方的地址
to - String: 交易接收方的地址,对于创建合约的交易,该值为null
contractAddress - String: 对于创建合约的交易,该值为创建的合约地址,否则为null
cumulativeGasUsed - Number: 该交易执行时所在块的gas累计总用量
gasUsed- Number: 该交易的gas总量
logs - Array: 该交易产生的日志对象数组
我们将 AidocVote.bin
中的gas
改成 2000000
personal.unlockAccount(eth.accounts[0])
var vote = VoteContract.new({
from: eth.accounts[0],
data: "0x608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073dca980c19d4b3782e7a21496f6b260432854d1e7600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061132a806100b66000396000f3006080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b187ab3146104615780630b34d553146104c65780631670a64a1461051d57806333cede131461057f5780634ffb203e146105d65780635e8885fb1461066757806360f292b5146106d457806366e41cb71461072f578063701b70ac14610786578063819f163a146107e15780638da5cb5b14610810578063a529794714610867578063bb52c137146108d4578063dc1e30da146108ff578063f2fde38b14610990578063f8a8fd6d146109d3575b6000803391503490506000811115156100fe57600080fd5b336000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101c96000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506102596000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610306573d6000803e3d6000fd5b507f7c6e301a3fc56528ab958cb48a309593cdca31df786612efd37ceb10e9aa86ae6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020154604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a15050005b34801561046d57600080fd5b506104ac600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a53565b604051808215151515815260200191505060405180910390f35b3480156104d257600080fd5b50610507600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bd1565b6040518082815260200191505060405180910390f35b34801561052957600080fd5b5061055e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c1d565b60405180838152602001821515151581526020019250505060405180910390f35b34801561058b57600080fd5b50610594610c4e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105e257600080fd5b50610617600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c74565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561067357600080fd5b5061069260048036038101908080359060200190929190505050610cbe565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106e057600080fd5b50610715600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d01565b604051808215151515815260200191505060405180910390f35b34801561073b57600080fd5b50610744610e42565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561079257600080fd5b506107c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e4a565b604051808215151515815260200191505060405180910390f35b3480156107ed57600080fd5b506107f6610ea3565b604051808215151515815260200191505060405180910390f35b34801561081c57600080fd5b50610825611015565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561087357600080fd5b506108926004803603810190808035906020019092919050505061103b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108e057600080fd5b506108e9611079565b6040518082815260200191505060405180910390f35b34801561090b57600080fd5b50610940600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611086565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561099c57600080fd5b506109d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061117e565b005b3480156109df57600080fd5b506109e86112d6565b60405180831515151581526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b6000808284019050838110151515610a4957fe5b8091505092915050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015410151515610aa557600080fd5b610af06000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154836112e5565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550610b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015483610a35565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055506001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001549050919050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16905082565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b6000600282815481101515610ccf57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d5f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610d9b57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610df857600080fd5b81600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600033905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff169050919050565b6000801515600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff161515141515610f0657600080fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548160ff02191690831515021790555060023390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028181548110151561104a57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600280549050905090565b60008060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549250925092509193909250565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111da57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561121657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060016000915091509091565b60008282111515156112f357fe5b8183039050929150505600a165627a7a7230582055c8f329f5744e02e0f7dd32cd6fed99bc45d7d57a535c54e1c21373ac328be70029",
gas: 2000000
})
重复刚才的步骤
> miner.start()
null
> miner.stop()
> vote
{
abi: [{
constant: false,
inputs: [{...}, {...}],
name: "makeVote",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getMinerInfo",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "minerMapping",
outputs: [{...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [],
name: "payeeAddress",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "voteMapping",
outputs: [{...}, {...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getMinerAddress",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [{...}],
name: "switchPayee",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "test2",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "isMiner",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [],
name: "addMiner",
outputs: [{...}],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "owner",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "minerArr",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [],
name: "getMinerCount",
outputs: [{...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: true,
inputs: [{...}],
name: "getVoteInfo",
outputs: [{...}, {...}, {...}],
payable: false,
stateMutability: "view",
type: "function"
}, {
constant: false,
inputs: [{...}],
name: "transferOwnership",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
}, {
constant: true,
inputs: [],
name: "test",
outputs: [{...}, {...}],
payable: false,
stateMutability: "pure",
type: "function"
}, {
inputs: [],
payable: false,
stateMutability: "nonpayable",
type: "constructor"
}, {
payable: true,
stateMutability: "payable",
type: "fallback"
}, {
anonymous: false,
inputs: [{...}, {...}, {...}],
name: "WithdrawCoin",
type: "event"
}, {
anonymous: false,
inputs: [{...}, {...}],
name: "OwnershipTransferred",
type: "event"
}],
address: "0xfd4464641855e45422af1a52e643a17844b747cd",
transactionHash: "0x876579851376007d84ed7c4b5307dcbf881b2df502e1c14dc48bdefb22dfcbc4",
OwnershipTransferred: function(),
WithdrawCoin: function(),
addMiner: function(),
allEvents: function(),
getMinerAddress: function(),
getMinerCount: function(),
getMinerInfo: function(),
getVoteInfo: function(),
isMiner: function(),
makeVote: function(),
minerArr: function(),
minerMapping: function(),
owner: function(),
payeeAddress: function(),
switchPayee: function(),
test: function(),
test2: function(),
transferOwnership: function(),
voteMapping: function()
}
> eth.getTransactionReceipt("0x876579851376007d84ed7c4b5307dcbf881b2df502e1c14dc48bdefb22dfcbc4")
{
blockHash: "0x39387edf581fa804664b9c8c4aea4f5de93508bc670407bfbcfe87e170ad08eb",
blockNumber: 29,
contractAddress: "0xfd4464641855e45422af1a52e643a17844b747cd",
cumulativeGasUsed: 1409258,
from: "0xf5d4331b11f119c36cfcc85effe0d3f3fec4a099",
gasUsed: 1409258,
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
root: "0x07c65c1dd50bea12d351f6445505b039725d7a38587988b7367eee239a510468",
to: null,
transactionHash: "0x876579851376007d84ed7c4b5307dcbf881b2df502e1c14dc48bdefb22dfcbc4",
transactionIndex: 0
}
>
address
已经有值说明部署成功, gas
我们设置了2000000
才消耗了1409258
gas
不足确实给我带来不少的麻烦,又浪费了gas
费用。以太坊提供了估算交易gas
消耗
> web3.eth.estimateGas({
from: eth.accounts[0],
data: "0x608060405234801561001057600080fd5b5033600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073dca980c19d4b3782e7a21496f6b260432854d1e7600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061132a806100b66000396000f3006080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b187ab3146104615780630b34d553146104c65780631670a64a1461051d57806333cede131461057f5780634ffb203e146105d65780635e8885fb1461066757806360f292b5146106d457806366e41cb71461072f578063701b70ac14610786578063819f163a146107e15780638da5cb5b14610810578063a529794714610867578063bb52c137146108d4578063dc1e30da146108ff578063f2fde38b14610990578063f8a8fd6d146109d3575b6000803391503490506000811115156100fe57600080fd5b336000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101c96000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055506102596000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206002015482610a35565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020181905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610306573d6000803e3d6000fd5b507f7c6e301a3fc56528ab958cb48a309593cdca31df786612efd37ceb10e9aa86ae6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020154604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390a15050005b34801561046d57600080fd5b506104ac600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a53565b604051808215151515815260200191505060405180910390f35b3480156104d257600080fd5b50610507600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bd1565b6040518082815260200191505060405180910390f35b34801561052957600080fd5b5061055e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c1d565b60405180838152602001821515151581526020019250505060405180910390f35b34801561058b57600080fd5b50610594610c4e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105e257600080fd5b50610617600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c74565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561067357600080fd5b5061069260048036038101908080359060200190929190505050610cbe565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106e057600080fd5b50610715600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d01565b604051808215151515815260200191505060405180910390f35b34801561073b57600080fd5b50610744610e42565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561079257600080fd5b506107c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e4a565b604051808215151515815260200191505060405180910390f35b3480156107ed57600080fd5b506107f6610ea3565b604051808215151515815260200191505060405180910390f35b34801561081c57600080fd5b50610825611015565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561087357600080fd5b506108926004803603810190808035906020019092919050505061103b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108e057600080fd5b506108e9611079565b6040518082815260200191505060405180910390f35b34801561090b57600080fd5b50610940600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611086565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828152602001935050505060405180910390f35b34801561099c57600080fd5b506109d1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061117e565b005b3480156109df57600080fd5b506109e86112d6565b60405180831515151581526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390f35b6000808284019050838110151515610a4957fe5b8091505092915050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015410151515610aa557600080fd5b610af06000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154836112e5565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010181905550610b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015483610a35565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055506001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001549050919050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16905082565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b6000600282815481101515610ccf57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d5f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610d9b57600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610df857600080fd5b81600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600033905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff169050919050565b6000801515600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff161515141515610f0657600080fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548160ff02191690831515021790555060023390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028181548110151561104a57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600280549050905090565b60008060008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101546000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549250925092509193909250565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111da57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561121657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060016000915091509091565b60008282111515156112f357fe5b8183039050929150505600a165627a7a7230582055c8f329f5744e02e0f7dd32cd6fed99bc45d7d57a535c54e1c21373ac328be70029"
})
>1409258
部署合约完成之后,调用合约中函数可能报下面错误:
(node:976) UnhandledPromiseRejectionWarning: Error: Couldn't decode bool from ABI: 0x
at SolidityTypeBool.formatOutputBool [as _outputFormatter] (/Users/zhangyueru/node_modules/web3-eth-abi/src/formatters.js:194:15)
at SolidityTypeBool.SolidityType.decode (/Users/zhangyueru/node_modules/web3-eth-abi/src/type.js:252:17)
at /Users/zhangyueru/node_modules/web3-eth-abi/src/index.js:327:49
at Array.forEach ()
at ABICoder.decodeParameters (/Users/zhangyueru/node_modules/web3-eth-abi/src/index.js:326:13)
at Contract._decodeMethodReturn (/Users/zhangyueru/node_modules/web3-eth-contract/src/index.js:464:22)
at Method.outputFormatter (/Users/zhangyueru/node_modules/web3-eth-contract/src/index.js:817:46)
at Method.formatOutput (/Users/zhangyueru/node_modules/web3-core-method/src/index.js:163:54)
at sendTxCallback (/Users/zhangyueru/node_modules/web3-core-method/src/index.js:476:33)
at /Users/zhangyueru/node_modules/web3-core-requestmanager/src/index.js:147:9
at XMLHttpRequest.request.onreadystatechange (/Users/zhangyueru/node_modules/web3-providers-http/src/index.js:79:13)
at XMLHttpRequestEventTarget.dispatchEvent (/Users/zhangyueru/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (/Users/zhangyueru/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (/Users/zhangyueru/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
at IncomingMessage. (/Users/zhangyueru/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1081:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:976) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:976) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will te
此类错误引起的有两个
1.合约地址不存在或错误
2.没有部署成功,查看 eth.getTransactionReceipt
和 交易中的gas
是否消耗完