In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use web3.eth.getBlock". In daily operation, I believe many people have doubts about how to use web3.eth.getBlock. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "how to use web3.eth.getBlock"! Next, please follow the small series to learn together!
Returns the block number or block hash corresponding to the block
Call:
web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])
Parameters:
blockHashOrBlockNumber: Number| String -(optional) If no parameters are passed, the block defined by web3.eth.defaultBlock is used by default, otherwise the specified block is used.
returnTransactionObjects: Boolean -(optional) Default is false. true returns all transactions contained in the block as objects. Otherwise, only the hash of the transaction is returned.
callback: Function -callback function, used to support asynchronous execution 7.
Return Value-Block Object:
Number -Block number. When the block is pending, null will be returned.
hash -String, hash string of blocks. When the block is pending, null will be returned.
parentHash -String, hash value of the parent block of 32 bytes.
nonce -String, 8 bytes. POW generated hash. When the block is pending, null will be returned.
sha3Uncles-String, 32 bytes. The hash value of the tertiary block.
logsBloom -String, Bloom filter of block log 9. When the block is pending, null will be returned.
transactionsRoot -String, 32 bytes, root of block's transaction prefix tree.
stateRoot -String, 32 bytes. The root of the prefix tree of the block's final state.
miner -String, 20 bytes. This block gets rewarded miners.
difficulty - BigNumber type. The difficulty of the current block, integer.
totalDifficulty - BigNumber type. The total difficulty of the block chain to the current block, integer.
extraData -String. The extra data field of the current block.
size - Number。The byte size of the current block.
gasLimit - Number, the maximum gas allowed for the current block.
gasUsed -Total gas used cumulatively for the current block.
timestamp - Number。The unix timestamp at the time the block was packaged.
transactions -Array. Transaction object. Or a 32-byte transaction hash.
uncles -Array. An array of uncle hashes.
Examples:
var info = web3.eth.getBlock(3150);console.log(info);/*{ "number": 3, "hash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46", "parentHash": "0x2302e1c0b972d00932deb5dab9eb2982f570597d9d42504c05d9c2147eaf9c88", "nonce": "0xfb6e1a62d119228b", "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "transactionsRoot": "0x3a1b03875115b79539e5bd33fb00d8f7b7cd61929d5a3c574f507b8acf415bee", "stateRoot": "0xf1133199d44695dfa8fd1bcfe424d82854b5cebef75bddd7e40ea94cda515bcb", "miner": "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty": BigNumber, "totalDifficulty": BigNumber, "size": 616, "extraData": "0x", "gasLimit": 3141592, "gasUsed": 21662, "timestamp": 1429287689, "transactions": [ "0x9 fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b" ], "uncles": []}*/At this point, the study of "how to use web3.eth.getBlock" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.