我在一个从node1到node2的私人连锁店上发送了1个ETH。
>eth.sendTransaction({
from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
gasPrice: "5000000000",
gas: "21000",
to: '0xdba556d4250060d8be5abc82f50653430cee5769',
value: "1000000000000000000",
data: ""
}, 'password')结果(TxHash)
"0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205"但是当我检查TxHash时
> eth.getTransaction("0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
gas: 21000,
gasPrice: 5000000000,
hash: "0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9129205",
input: "0x",
nonce: 8,
r: "0xbe40d0d29d00b48459ba36933eec4338065d2eb5511855316b8fa237c43c95ca",
s: "0x568b749c609e9dfea9d35fad8e372a747a6eeedb58bbecd20103f8a2dd88cce3",
to: "0xdba556d4250060d8be5abc82f50653430cee5769",
transactionIndex: 0,
v: "0x9c8",
value: 1000000000000000000
}检查收信人的交易数量,
> eth.getTransactionCount("0xdba556d4250060d8be5abc82f50653430cee5769")
0交易成功了吗?
genesis.json
{
"config": {
"chainID": 1234,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {
"0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b": {
"balance": "100000000000000000000000000000"
}
},
"difficulty": "0x4000",
"gasLimit": "0xffffffff",
"nonce": "0x0000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x123458db4e347b1234537c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"timestamp": "0x00"
}交易收据:
> eth.getTransactionReceipt("0xfd723065f3c389b91d379450caad235066762c53749780459 218218ff9129205")
{
blockHash: "0x305262bbae04f2646d55724c4e87e836e558cc2c30bd874c2b2c768622113832 ",
blockNumber: 30198,
contractAddress: null,
cumulativeGasUsed: 21000,
from: "0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b",
gasUsed: 21000,
logs: [],
logsBloom: "0x0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000",
root: "0xafbb5fe68186740e11cab692ad5c3b88a1b450cc27f93a2a627138a8a347d155",
to: "0xdba556d4250060d8be5abc82f50653430cee5769",
transactionHash: "0xfd723065f3c389b91d379450caad235066762c53749780459218218ff9 129205",
transactionIndex: 0
}发布于 2019-04-14 14:09:40
这是因为getTransactionCount(address)返回从地址发送的事务数。您正在传递接收eth的地址,因此它的计数将为0。如果您尝试使用0x30278b135d0f5c10eb0684ff18bfd84912ae0f2b,它应该会给您1。
发布于 2019-04-14 17:29:36
就我个人而言,我不会依赖getTransactionCount来验证事务是否成功。我将使用getBalance检查接收地址的余额。
> eth.getBalance("0xdba556d4250060d8be5abc82f50653430cee5769")或者,如果您想使用web3 https://web3js.readthedocs.io/en/1.0/web3-eth.html#getbalance
https://ethereum.stackexchange.com/questions/69655
复制相似问题