# Deploy the token bridge contract · Chromia Docs (concept)

> This section walks through deploying the token bridge contract on BSC Testnet, enabling ERC20 token transfers between Chromia and EVM-compatible networks.

Source: https://docs.chromia.com/ecosystem/bridge/deploy-bridge/deploy-bridge-contract/

# Deploy the token bridge contract

On this page

* [Prerequisites](#prerequisites)
* [1. Set the directory validator address](#1-set-the-directory-validator-address)
* [2. Deploying validator contract](#2-deploying-validator-contract)
* [For manually updated validator contracts:](#for-manually-updated-validator-contracts)
* [For managed validator contract](#for-managed-validator-contract)
* [Inspecting the validator contract](#inspecting-the-validator-contract)
* [3. Deploy the token bridge contract](#3-deploy-the-token-bridge-contract)
* [4. Register the ERC20 token with the bridge](#4-register-the-erc20-token-with-the-bridge)

This section walks through **deploying the token bridge contract on BSC Testnet**, enabling ERC20 token transfers
between Chromia and EVM-compatible networks.

## Prerequisites

Before proceeding, ensure you have the following:

* **[Chromia CLI](https://docs.chromia.com/get-started/installation/)**
* **[ERC20 token address](https://docs.chromia.com/ecosystem/bridge/deploy-bridge/deploy-erc20-token/)**
* **[Node.js](https://nodejs.org/)**
* **[MetaMask](https://metamask.io/)** or a compatible wallet.
* **[Test BNB tokens](https://www.bnbchain.org/en/testnet-faucet)** or the respective native tokens for gas fees.
* **[Postchain EIF contracts repository](https://gitlab.com/chromaway/core/postchain-eif.git)**

If you haven't cloned the repository yet, run:

Terminal

```
git clone https://gitlab.com/chromaway/core/postchain-eif.git
```

## 1. Set the directory validator address

Set the **Directory Chain validator** address based on your target network:

Terminal

```
# BSC Testnet
export DIRECTORY_VALIDATOR=0x83dB85F7ef4447524D3A31c0F4664a89173C68Eb
```

Terminal

```
# BSC Mainnet
export DIRECTORY_VALIDATOR=0xc755927508b7Ac3f7B31c9Ed396F3bE91C723d00
```

Terminal

```
# Ethereum Mainnet
export DIRECTORY_VALIDATOR=0xc755927508b7Ac3f7B31c9Ed396F3bE91C723d00
```

This guide focuses on **BSC Testnet**, but if deploying on **BSC Mainnet or Ethereum Mainnet**, use the appropriate
validator address.

## 2. Deploying validator contract

Each bridge contract requires a validator contract. There are three types:

* **Manually updated validator**:  
  The contract owner updates the validator set manually. Suitable for testing or fixed validator configurations.
* **Managed validator**:  
  It is automatically updated by Chromia’s Transaction Submitter chain when validator changes occur. It is ideal for
  dapp developers building bridge applications.
* **Directory Chain validator**:  
  Used in custom Chromia networks to track the system cluster's validators. It is not deployed by dapp developers but is
  required when setting up managed validators.

### For manually updated validator contracts:

Terminal

```
npx hardhat deploy:validator --network sepolia --verify --validators {VALIDATOR_0_ADDRESS},{VALIDATOR_1_ADDRESS},{VALIDATOR_2_ADDRESS}
```

Here, `{VALIDATOR_i_ADDRESS}` represents the EVM address (with `0x` prefix) corresponding to the Chromia public key of
`node_i`, and can be calculated using the following command:

Terminal

```
chr repl -c 'crypto.eth_pubkey_to_address(x"0338BB1915D6DD2E343524CF48CFBD2B53DB2A099D44FAD1D1206F516872754542")'
x"1B3821093FDCC3EFE225EF0835FE34DABABC60D3"
```

### For managed validator contract

If you already know the blockchain RID of your chain, you can supply it with `--blockchain-rid` (0x-prefixed):

Terminal

```
npx hardhat deploy:validator --network sepolia --verify --directory-validator {DIRECTORY_VALIDATOR_CONTRACT_ADDRESS}
```

### Inspecting the validator contract

Terminal

```
# For manually updated validators
npx hardhat inspect:validator --network sepolia --validator-address {VALIDATOR_CONTRACT_ADDRESS}
```

Terminal

```
# For managed validators
npx hardhat inspect:managedValidator --network sepolia --validator-address {VALIDATOR_CONTRACT_ADDRESS}
```

Terminal

```
# For directory chain validators
npx hardhat inspect:directoryValidator --network sepolia --validator-address {VALIDATOR_CONTRACT_ADDRESS}
```

## 3. Deploy the token bridge contract

Run the following command to deploy the bridge contract:

Terminal

```
npx hardhat deploy:bridge --network bsc_testnet --validator-address $DIRECTORY_VALIDATOR --offset 2
```

* `--network bsc_testnet`: Deploys to BSC Testnet
* `--validator-address $DIRECTORY_VALIDATOR`: Sets the directory validator contract
* `--offset 2`: The dispute or withdrawal lock period (in blocks).

After deployment, the terminal will display the deployed contract addresses:

Terminal

```
Token bridge deployed to: 0x....................
Proxy admin address: 0x....................
```

tip

Copy and save the **bridge contract address** for future use.

## 4. Register the ERC20 token with the bridge

After deploying the bridge contract, register your ERC20 token:

Terminal

```
npx hardhat allowToken:bridge --network bsc_testnet --bridge-address 0x{YOUR_BRIDGE_ADDRESS} --token-address 0x{YOUR_TOKEN_ADDRESS}
```

This enables deposits and withdrawals for your ERC20 token on the bridge.

[View this page on docs.chromia.com](https://docs.chromia.com/ecosystem/bridge/deploy-bridge/deploy-bridge-contract/)Content mirrored from the live docs
