Block Module
4.1 Get Current Block
get_currentfrom crypto_com_developer_platform_client import Block block = Block.get_current() print(block)
The latest block data.ValueError: If the Block class is not initialized with a Client instance.{'status': 'Success', 'data': {'blockNumber': example-block-number}}
getCurrentBlockimport { Block } from '@crypto.com/developer-platform-client'; const block = await Block.getCurrentBlock(); console.log(block);
Promise<ApiResponse<BlockNumber>>: A promise that resolves to the current block data.{ status: 'Success', data: { blockNumber: example-number } }
4.2 Get Block By Tag
get_by_tagtag (str): Integer of a block number in hex, or the string "earliest", "latest" or "pending", as in https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block tx_detail (str): If true it returns the full transaction objects, if false only the hashes of the transactions.from crypto_com_developer_platform_client import Block block = Block.get_by_tag("latest", "true") print(block)
The block data.ValueError: If the Block class is not initialized with a Client instance.{'status': 'Success', 'data': {'block': {'_type': 'Block', 'baseFeePerGas': 'example-fee', 'difficulty': 'example-difficulty', 'extraData': 'example-data', 'gasLimit': 'example-gas-limit', 'gasUsed': 'example-gas-used', 'blobGasUsed': 'example-blob-gas-used', 'excessBlobGas': 'example-gas', 'hash': 'example-hash', 'miner': 'example-address', 'prevRandao': 'example-randao', 'nonce': 'example-nonce', 'number': example-number, 'parentHash': 'example-hash', 'timestamp': example-timestamp, 'parentBeaconBlockRoot': 'example-hash', 'stateRoot': 'example-hash', 'receiptsRoot': 'example-hash', 'transactions': ['example-transactions']}}}
getBlockByTag(string} blockTag: Block identifier ('latest', 'pending', or block number in hex). {string} txDetail: Whether to include transaction details ('true' or 'false').import { Block } from '@crypto.com/developer-platform-client'; const block = await Block.getBlockByTag('latest', 'true'); console.log(block);
Promise<ApiResponse<BlockData>>: A promise that resolves to the block data.{ status: 'Success', data: { block: { _type: 'Block', baseFeePerGas: 'example-fee', difficulty: 'example-difficulty', extraData: 'example-data', gasLimit: 'example-gas-limit', gasUsed: 'example-gas-used', blobGasUsed: example-gas, excessBlobGas: example-gas, hash: 'example-hash', miner: 'example-hash', prevRandao: 'example-hash', nonce: 'example-nonce', number: example-number, parentHash: 'example-hash', timestamp: example-timestamp, parentBeaconBlockRoot: example-block-root, stateRoot: 'example-hash', receiptsRoot: 'example-hash', transactions: [example-transaction-array] } } }
Last updated
Was this helpful?