Configure the Chromia bridge client
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
TokenBridgecontract 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
hbridgeRell library.
Configuration checklist
-
Approve ERC20 token
The ERC20 token must be approved by the
TokenBridgecontract owner using theallowTokenfunction. You can accomplish this with the@chromia/bridge-clientusing theallowTokenmethod:const contractTransactionResponse = await bcl.allowToken(token); -
Check spending allowance
Verify the spending allowance with the
checkAllowancemethod:const allowance: bigint = await bcl.checkAllowance(); -
Set blockchain RID
Use the
setBlockchainRidfunction in theTokenBridgecontract to set the blockchain RID. You can use the built-in methodsetBlockchainRidwith@chromia/bridge-client: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
updateValidatorsfunction.