This script is to be used in the geth console to get the information in a blockchain
- Open geth console connecting to your node rpc/ipc address. For example, if the default geth node port is 8545, type
geth attch http://localhost:8545
to connect to the node and open geth console - In geth console, type
loadScript('path_of_this_script')
to load this script. It will return true if the script is loaded successfully - As defined in the script, run
init()
for intitialization and then rungetInfo()
to get the blockchain information. Everytime the blockchain is updated, rungetInfo()
again to retrieve the lastest data.
- blocks: an array containing info of all current blocks
- gasUsed: total gas used by now
- tnxHashes: an array containing all transaction hashes
- totalDifficulties: an array of the mining difficulty of each block
- emptyBlockNum: the number of empty blocks (blocks with no transactions)
- blockMiningTime: the time between each block is mined in seconds
- tnxReceipts: an array of all transaction info (The
from
andto
addresses will be undefined if the transaction is not a standardsendTransaction
)