Skip to main content

Chain Data

Get Hedera's chain information using Arkhia's Json-RPC Relay.

info

To configure your web3Provider, please refer to the Getting Started Docs:

eth_chainId

Get chain id.

Parameters

None

Returns

Hex string or Integer: Current chain id

web3Provider.eth.getChainId()    .then((res) => console.log(`-> get chain ID`, res))    .catch(e => console.log('-> get chain ID error: ' + e));

eth_blockNumber

Get the current block number.

Parameters

None

Returns

Hex string or Integer: Current block number

web3Provider.eth.getBlockNumber()    .then((res) => console.log(`-> get block number`, res))    .catch(e => console.log('-> get block number error: ' + e));

eth_gasPrice

Get the current gas price.

Parameters

None

Returns

String: Current gas price

web3Provider.eth.getGasPrice()    .then((res) => console.log(`-> get gas price`, res))    .catch(e => console.log('-> get gas price error: ' + e));

eth_estimateGas

Get the current gas price.

Parameters

  • Transaction: Transaction object Required

    • from - String|Number: The address for the sending account. Uses the web3.eth.defaultAccount property, if not specified. Or an address or index of a local wallet in web3.eth.accounts.wallet.
    • to - String: (optional) The destination address of the message, left undefined for a contract-creation transaction.
    • value - Number|String|BN|BigNumber: (optional) The value transferred for the transaction in wei, also the endowment if it’s a contract-creation transaction.
    • gas - Number: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).
    • gasPrice - Number|String|BN|BigNumber: (optional) The price of gas for this transaction in wei, defaults to web3.eth.gasPrice.
    • data - String: (optional) Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialisation code.
    • nonce - Number: (optional) Integer of the nonce. This allows to overwrite your own pending transactions that use the same nonce.
    • chain - String: (optional) Defaults to mainnet.
  • Block: Integer block number, or the string "latest", "earliest" or "pending", see the default block parameter

Returns

Hex string or Integer: estimated gas for the transaction

web3Provider.eth.estimateGas({    from: "0x0030002e0030002e003400320032003700350035"})    .then((res) => console.log(`-> get Gas`, res))    .catch(e => console.log('-> get Gas error: ' + e));

eth_getBlockByHash

Get block details using the block hash.

Parameters

  • Block hash: Hash of the block Required

Returns

The block information

/*<BLOCK_HASH> can be found on hashscan https://hashscan.io/#/mainnet/dashboardfor example: 0x8b7de6e435b5a1f0f9b3dd49a7943bc654b86930abecf22792e45e203e3fe8fac17d7c93af28e079bf71908babf0d5f8*/web3Provider.eth.getBlock(`<BLOCK_HASH>`)    .then((res) => console.log(`-> get block by hash`, res))    .catch(e => console.log('-> get block by hash error: ' + e));

eth_getBlockByNumber

Get block details using the block number.

Parameters

  • Block number: Number of the block or block tag (earliest, latest, pending) Required

Returns

The block information

/*<BLOCK_NUMBER> can be found on hashscan https://hashscan.io/#/mainnet/dashboardfor example: 38453581*/web3Provider.eth.getBlock(`<BLOCK_NUMBER>`)    .then((res) => console.log(`-> get block by number`, res))    .catch(e => console.log('-> get block by number error: ' + e));