Skip to main content

getChainId

Callable

  • getChainId<ReturnFormat>(web3Context: Web3Context<EthExecutionAPI, any>, returnFormat: ReturnFormat): Promise<NumberTypes[ReturnFormat[number]]>

  • Type parameters

    • ReturnFormat: DataFormat

    Parameters

    • web3Context: Web3Context<EthExecutionAPI, any>

      (Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.

    • returnFormat: ReturnFormat

      (DataFormat defaults to DEFAULT_RETURN_FORMAT) - Specifies how the return data from the call should be formatted.

    Returns Promise<NumberTypes[ReturnFormat[number]]>

    The chain ID of the current connected node as described in the EIP-695.

    web3.eth.getChainId().then(console.log);
    > 61n

    web3.eth.getChainId({ number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
    > 61