Day 9 :
繼連結了節點之後,在節點1發送交易,使用節點2來查詢。
-首先,在節點1確認帳戶
eth.accounts[0] <= 發送方
eth.accounts[1] <= 接收方
-解鎖帳戶
>personal.unlockAccount(eth.accounts[0],"123456");
true
-發送交易 :
eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(5,”ether”)})
-節點1查詢交易狀態
>eth.getTransaction("0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d")
{
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
blockNumber: null,
from: "0x4ca5f4a1612ebe48d8e48c7df7b2f0d2839ebc56",
gas: 90000,
gasPrice: 1000000000,
hash: "0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d",
input: "0x",
nonce: 1,
r: "0x9beb5e80ceb65cae6ce6ad0796f910df8b3c0c510d5267c91efa5f611b50ed95",
s: "0x4f870eb67ed31c25b7df13d9b5709d87e77ba7c95b7e458487ea05e29acd7666",
to: "0x385843e41e52c9671eba67562a76c4cd2debe16d",
transactionIndex: 0,
v: "0x4b",
value: 5000000000000000000
}
-查詢交易緩衝區
> txpool.inspect.pending
{
0x4ca5F4A1612EBe48d8E48c7dF7B2f0d2839EbC56: {
1: "0x385843E41e52c9671EBa67562A76c4cd2dEbE16d: 5000000000000000000 wei + 90000 gas × 1000000000 wei"
}
}
交易尚未被寫入區塊。
-節點1執行挖礦
miner.start(1);admin.sleepBlocks(1);miner.stop();
挖一次礦之後,停止挖礦。
-節點2查詢交易狀態
>eth.getTransaction("0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d");
{
blockHash: "0xc2ac858def8953cdfc32fc32a717661fca405a006840ecc703b20335e2ac9dc4",
blockNumber: 13,
from: "0x4ca5f4a1612ebe48d8e48c7df7b2f0d2839ebc56",
gas: 90000,
gasPrice: 1000000000,
hash: "0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d",
input: "0x",
nonce: 1,
r: "0x9beb5e80ceb65cae6ce6ad0796f910df8b3c0c510d5267c91efa5f611b50ed95",
s: "0x4f870eb67ed31c25b7df13d9b5709d87e77ba7c95b7e458487ea05e29acd7666",
to: "0x385843e41e52c9671eba67562a76c4cd2debe16d",
transactionIndex: 0,
v: "0x4b",
value: 5000000000000000000
}
-節點2查詢交易收據
>eth.getTransactionReceipt("0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d");
{
blockHash: "0xc2ac858def8953cdfc32fc32a717661fca405a006840ecc703b20335e2ac9dc4",
blockNumber: 13,
contractAddress: null,
cumulativeGasUsed: 21000,
from: "0x4ca5f4a1612ebe48d8e48c7df7b2f0d2839ebc56",
gasUsed: 21000,
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
root: "0xf822d4ed8ecb5a153c7ac1a98dd5728c46dc6114e38fea3bfa4ec7a41227c4ab",
to: "0x385843e41e52c9671eba67562a76c4cd2debe16d",
transactionHash: "0xae187354f775a34247499cdf58b27a5d11d768435c2a4b6c2ca3828b57896b2d",
transactionIndex: 0
}
藉由此次操作,觀察節點之間同步數據的情形。