- web3
- web3.version.api
- web3.version.node
- web3.version.network
- web3.version.ethereum
- web3.version.whisper
- web3.isConnected
- web3.setProvider
- web3.currentProvider
- web3.reset
- web3.sha3
- web3.toHex
- web3.toAscii
- web3.fromAscii
- web3.toDecimal
- web3.fromDecimal
- web3.fromWei
- web3.toWei
- web3.toBigNumber
- web3.net.listening
- web3.net.peerCount
- web3.eth
- web3.eth.defaultAccount
- web3.eth.defaultBlock
- web3.eth.syncing
- web3.eth.isSyncing
- web3.eth.coinbase
- web3.eth.mining
- web3.eth.hashrate
- web3.eth.gasPrice
- web3.eth.accounts
- web3.eth.blockNumber
- web3.eth.register
- web3.eth.unRegister
- web3.eth.getBalance
- web3.eth.getStorageAt
- web3.eth.getCode
- web3.eth.getBlock
- web3.eth.getBlockTransactionCount
- web3.eth.getUncle
- web3.eth.getTransaction
- web3.eth.getTransactionFromBlock
- web3.eth.getTransactionReceipt
- web3.eth.getTransactionCount
- web3.eth.sendTransaction
- web3.eth.sendRawTransaction
- web3.eth.sign
- web3.eth.call
- web3.eth.estimateGas
- web3.eth.filter
- web3.eth.contract
- web3.eth.getCompilers
- web3.eth.compile.solidity
- web3.eth.compile.lll
- web3.eth.compile.serpent
- web3.eth.namereg
- web3.db.putString
- web3.db.getString
- web3.db.putHex
- web3.db.getHex
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
web3.eth.getBlock
web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])
返回块号或区块哈希值所对应的区块
参数:
Number|String
-(可选)如果未传递参数,默认使用web3.eth.defaultBlock
定义的块,否则使用指定区块。Boolean
-(可选)默认值为false
。true
会将区块包含的所有交易作为对象返回。否则只返回交易的哈希。Function
- 回调函数,用于支持异步的方式执行[async]。
返回值 - 区块对象:
Number
- 区块号。当这个区块处于pending
将会返回null
。hash
- 字符串,区块的哈希串。当这个区块处于pending
将会返回null
。parentHash
- 字符串,32字节的父区块的哈希值。nonce
- 字符串,8字节。POW生成的哈希。当这个区块处于pending
将会返回null
。sha3Uncles
- 字符串,32字节。叔区块的哈希值。logsBloom
- 字符串,区块日志的布隆过滤器9。当这个区块处于pending
将会返回null
。transactionsRoot
- 字符串,32字节,区块的交易前缀树的根。stateRoot
- 字符串,32字节。区块的最终状态前缀树的根。miner
- 字符串,20字节。这个区块获得奖励的矿工。difficulty
-BigNumber
类型。当前块的难度,整数。totalDifficulty
-BigNumber
类型。区块链到当前块的总难度,整数。extraData
- 字符串。当前块的extra data
字段。size
-Number
。当前这个块的字节大小。- gasLimit -
Number
,当前区块允许使用的最大gas
。 gasUsed
- 当前区块累计使用的总的gas
。timestamp
-Number
。区块打包时的unix
时间戳。transactions
- 数组。交易对象。或者是32字节的交易哈希。uncles
- 数组。叔哈希的数组。
示例:
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": [
"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
],
"uncles": []
}
*/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论