Go-Ethereum
如何在私人測試網上跟踪失去的交易?
我無法讓幾筆測試交易顯示在目標賬戶餘額中。程式碼如下。感謝有人指出我所做的任何舉動……
執行 geth 為:
geth --rpc --networkid=34534 --maxpeers=0 --datadir=~/.ethereum/DevChain/ --mine --minerthreads 1 --genesis development_genesis.json console
控制台會話:
> var receiver = eth.accounts[1]; undefined > var amount = web3.toWei(1, "ether") undefined > var amount = web3.toWei(2, "ether") undefined > personal.unlockAccount(eth.accounts[0], “passwd”, 9000) true > eth.sendTransaction({from:sender, to:receiver, value: amount}) I0401 19:49:03.928354 eth/api.go:1072] Tx(0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40) to: 0x9a22b931b03768958141afa40d66fa587c7bfd3a "0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40" > eth.pendingTransactions [{ blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000", blockNumber: null, from: "0x87fa50f10eda0ee47376427d4623deae9577c048", gas: "0x15f90", gasPrice: "0x4a817c800", hash: "0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40", input: "0x", nonce: "0x0", to: "0x9a22b931b03768958141afa40d66fa587c7bfd3a", transactionIndex: null, value: "0x1bc16d674ec80000" }] > > miner.start(1) I0401 19:49:13.013921 miner/miner.go:119] Starting mining operation (CPU=1 TOT=2) true > I0401 19:49:13.044968 miner/worker.go:564] commit new work on block 28 with 1 txs & 0 uncles. Took 31.004161ms > checkAllBalances() eth.accounts[0]: 0x87fa50f10eda0ee47376427d4623deae9577c048 balance: 135 ether eth.accounts[1]: 0x9a22b931b03768958141afa40d66fa587c7bfd3a balance: 0 ether
我想在第二個帳戶中看到 2 個乙太幣。(實際上 3 乙太幣,因為之前的交易似乎也從未通過。)
checkAllBalances() 是:
function checkAllBalances() { var i =0; eth.accounts.forEach( function(e){ console.log(" eth.accounts["+i+"]: " + e + " \tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether"); i++; }) };
在開采了大約 5 個區塊之後,轉移的 2 個乙太幣終於出現了。這是預期的行為嗎?
但後來我又發送了 3 個乙太幣,它顯示在其他賬戶餘額中的速度要快得多。現在我有 0.5 個乙太幣待處理,挖礦輸出辨識出 1 筆交易,但 eth.pendingTransactions 仍然顯示它待處理。
是否有私人測試網區塊瀏覽器?
想要一種插入交易並了解正在發生的事情的方法。
在我學習基礎知識時感謝您的提示!
是的。這是預期的行為。當交易被包含到一個開采的區塊中時,交易將被確認並包含到區塊鏈中。這將需要至少一個開采的區塊。
我不知道有任何私人測試網瀏覽器。
在乙太坊 geth 控制台中跟踪交易的方式是跟踪執行 eth.sendTransaction(…) 命令後顯示的交易雜湊,然後您可以使用 eth.getTransaction(…) 檢索交易詳細資訊。在下面的範例中,交易在區塊 84 中被探勘。在交易被探勘之前,blockHash 和 blockNumber 將為空。
> eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], web3.toWei(2, "ether")}) "0xe548890adc667af1f0b9694ddd9da75dd85d17d6ffcaef62aedb63389ac2da9b" > eth.getTransaction("0xe548890adc667af1f0b9694ddd9da75dd85d17d6ffcaef62aedb63389ac2da9b") { blockHash: null, blockNumber: null, from: "0x1111903a542ef1ff952eab096eab0517a7d4eeee", gas: 90000, gasPrice: 20000000000, hash: "0xe548890adc667af1f0b9694ddd9da75dd85d17d6ffcaef62aedb63389ac2da9b", input: "0x", nonce: 0, to: "0x22222a45dce56b6804bbf6a2dc8fae045511ffff", transactionIndex: null, value: 1000000000000000000 } ... transaction mined ... > eth.getTransaction("0xe548890adc667af1f0b9694ddd9da75dd85d17d6ffcaef62aedb63389ac2da9b") { blockHash: "0xc74d2b08c28b801344006e477fe99cdc7cd6f3936a4223135eec7b42a04bf999", blockNumber: 84, from: "0x1111903a542ef1ff952eab096eab0517a7d4eeee", gas: 90000, gasPrice: 20000000000, hash: "0xe548890adc667af1f0b9694ddd9da75dd85d17d6ffcaef62aedb63389ac2da9b", input: "0x", nonce: 0, to: "0x22222a45dce56b6804bbf6a2dc8fae045511ffff", transactionIndex: 0, value: 1000000000000000000 }