Docs
chromia.com

Configure the Chromia bridge client

On this page

The Chromia bridge client is a TypeScript library with utilities for interacting with the Chromia Token Bridge. This topic will walk you through setting up the Chromia bridge client to facilitate token transfers between Chromia and Ethereum Virtual Machine (EVM) networks.

Prerequisites

Before you begin, ensure you have the following:

  • TokenBridge contract: The address of a deployed TokenBridge contract on an EVM network.
  • ERC20 token contract: The address of an ERC20 token on the same EVM network.
  • Blockchain RID: The RID of a Chromia blockchain using the hbridge Rell library.

Configuration checklist

  • Approve ERC20 token

    The ERC20 token must be approved by the TokenBridge contract owner using the allowToken function. You can accomplish this with the @chromia/bridge-client using the allowToken method:

    TypeScript
    const contractTransactionResponse = await bcl.allowToken(token);
  • Check spending allowance

    Verify the spending allowance with the checkAllowance method:

    TypeScript
    const allowance: bigint = await bcl.checkAllowance();
  • Set blockchain RID

    Use the setBlockchainRid function in the TokenBridge contract to set the blockchain RID. You can use the built-in method setBlockchainRid with @chromia/bridge-client:

    TypeScript
    const contractTransactionResponse = await bcl.setBlockchainRid(rid);
  • Validator configuration

    Convert the public keys of the validating nodes in the Chromia network to EVM addresses and configure them in the Validator contract, either during deployment or by calling the updateValidators function.