Solidity

如何以程式方式獲取誰贏得了區塊獎勵?

  • May 18, 2018

由於像 etherscan.io 這樣的塊瀏覽器,我知道該塊是由哪個池解決的。

在此處輸入圖像描述

但是區塊鏈中的資訊在哪裡,我如何以程式方式獲取它?

你可以使用 web3 庫,當你連接到你的節點(geth\parity)時,你可以使用這個命令

web3.eth.getBlock('latest') 

以下是您將得到的:

author: '0xea674fdde714fd979de3edf0f56aa9716b898ec8',
difficulty: '1409289537104996',
extraData: '0x65746865726d696e652d657537',
gasLimit: 6712392,
gasUsed: 420000,
hash: '0xf18de65db65959d1598799c99216f74bb6bd37660791ca1047112d8250b29e5f',
logsBloom:'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
miner: '0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8',
mixHash:'0x83554e4f7da70e8e6d5a09f3eac24a3c88c775d7bef5c0fb9ab7fdfc36754a07',
nonce: '0x8d071d6023e37609',
number: 4564200,
parentHash: '0x339ba308c6b73e177628b67f231b96c6b52b2431cb1db404c013056513013c0a',
receiptsRoot: '0x824c56f642d67e881555ec142168cc2364a1343129e34044dea382088cb5fa42',
sealFields:[ '0xa083554e4f7da70e8e6d5a09f3eac24a3c88c775d7bef5c0fb9ab7fdfc36754a07',
'0x888d071d6023e37609' ],
sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
size: 2753,
stateRoot: '0x27e8d0873604aa13debb03388ed6f5b1a366722406bfce0971b9436df1104e48',
timestamp: 1510846002,
totalDifficulty: '1479149419700984138800',
transactions:
[ '0x112a4ee9748826b5704bc2bbab26624f8d5fc7ff3f803cb10e301a181ee0c86d',
'0xbc193c53b8541ea9ab9eba0f372f332917f19b8fac03eaa06542a07ed2545f2a',
'0xfa6be62d971bffecfb283b62752e547092d5802f3cbb849cdaa2750652b3d52c',
'0x05d1315cf61be9e1926d6f190cc8ff27591b8a2ce52b5e39b71001bccc371143',
'0xd75e0884fb3db98bc6d4ccddf4702ec92811d14ead9a1dac2ee0b8974b4c4488',
'0xb4794a09862a26206971a91c80748efaf5b401263ac5c08dfcc1a81f2c16ba9b',
'0x7f4da3a839dffbbf2d3c75df1a7188d8346b48546536772fea98aa1320fbb5e1',
'0x7da4b74bee197d5ba53cfa7b56b915e23f6007c4ced163140dd6ae5e1233cbc1',
'0x19295f620e02696d5c9490182e75fa8e4f8f80cddaa8e79c657f07c89f9696c0',
'0xe1e8fa928a3570cc614e8c4971fe831bbe2385a4fd7cee33df49c8da9fd9c3a7',
'0xeb096a7e698bde20b8dd5e89e52748589db29dfa572a1164c1019edc3132baf3',
'0xfead068593c461722daeca068a9b30887ad6a7d6cd33b0bf50a5c05081511fc7',
'0x3a651991b75bac463c7d47c99b4a9e7e7ad347b7591c7a1317e7b91131174c3d',
'0x84e6cbb0c44b233e19e095a7c293f1d5c00249903ce439edafd9b3bf88fbd990',
'0xcec9c58b27a6b8fb02a95cd9e593853e532ec9523ef7a1c3f068224d7457e236',
'0x60ab2af3f0bee2007b224853ee30fdd82a2d8bba88ee8c93fbd670f223893e27',
'0x4460b53d6ad5d53a2cb80c702fe244d1dad1632bdea3007e4b7c55f9f7aeabbd',
'0x292775c4b10f88a094d3ffb798ef54f685bde80c4f31601b616784575c88875e',
'0xcfb90d4345580d1f77830a961f6454365ca0e644dc8a3b13f87d28a4f5a02c48',
'0x067aaad3ae876b235070075e2d7e426640b0cc6f14b1ac6810bf6f70d28d9466' ],
transactionsRoot: '0x50978dc0ce98802b5a32e6422e61ca7d3d1f2ee02d13a6785919aa3c4b08a4f0',
uncles: [] }

您將獲得有關該區塊的所有資訊,並且礦工的地址也在其中

如果您使用的是 geth,請在命令中鍵入geth attach並按 enter ,然後鍵入eth.getBlock('latest')以獲取詳細資訊。

在執行之前geth attach,執行你的霧,以便 geth 自動連接到它。

謝謝你。

引用自:https://ethereum.stackexchange.com/questions/32687