Skip to main content

Set up the bridge demo app

This section guides you through cloning the chromia-bridge-demo repository and configuring the app to interact with your deployed token and bridge contracts.

Clone the bridge demo repository

Begin by cloning the chromia-bridge-demo repository to your local machine:

git clone https://bitbucket.org/chromawallet/chromia-bridge-demo.git
cd chromia-bridge-demo

Configure the event_receiver chain

Set the token bridge contract address

Open the ./rell/chromia.yml file and specify the token bridge contract address:

blockchains:
event_receiver:
eif:
chains:
bsc:
contracts: 0x7EE9dfbDF18c609a5e1AB0180c8A2ec6D473E093

Install the FT4 Rell library

Install the required library for your project:

chr install

Build and run the event receiver

To obtain the blockchain RID, build and start the event receiver:

chr build
chr node start --name event_receiver --node-properties config/node-config.properties --wipe

You should see output indicating that the event receiver has started successfully:

Starting node with pubkey: 0338BB1915D6DD2E343524CF48CFBD2B53DB2A099D44FAD1D1206F516872754542
INFO 2024-09-20 23:10:55.962 - [main] PostchainNode Exposing Prometheus metrics on port 9090
...
Starting blockchain event_receiver with brid 6613EA1B36823AA67D65C6104BB93A789089D0E568939FD6CBACCE6AFF1D0859 on id 0

Configure the bridge_demo chain

Update the bridge_demo config

In the same ./rell/chromia.yml file, set the blockchains > bridge_demo > icmf.receiver > local > bc-rid to the blockchain RID obtained from the event receiver:

bridge_demo:
module: main
config:
...
icmf:
receiver:
local:
- bc-rid: x"6613EA1B36823AA67D65C6104BB93A789089D0E568939FD6CBACCE6AFF1D0859"
topic: "L_evm_block_events"

Set ERC20 token properties

Update the ERC20 token properties in the same file, specifying bsc_asset_network_id as 97:

bridge_demo:
moduleArgs:
main:
bsc_asset_network_id: 97
# Add other properties as needed

Build the bridge_demo chain

After updating the configuration, build and run the bridge demo chain:

chr build
chr node start --node-properties config/node-config.properties

You should see both chains starting successfully:

Starting blockchain event_receiver with brid 6613EA1B36823AA67D65C6104BB93A789089D0E568939FD6CBACCE6AFF1D0859 on id 0
Starting blockchain bridge_demo with brid AB889D51EECC3A063B2430084BB6EA5EC3A1EAB866AC62CAA553D8758933CADA on id 1

Initialize the bridge_demo chain

Initialize the chain

To initialize the bridge_demo chain, run the following command:

chr tx --api-url http://localhost:7740 -brid AB889D51EECC3A063B2430084BB6EA5EC3A1EAB866AC62CAA553D8758933CADA init

Set the blockchain RID on the bridge contract

To configure the bridge demo blockchain RID on the token bridge contract, follow these steps:

  1. Navigate to the contract directory:

    cd postchain-eif/postchain-eif-contracts
  2. Run the command to set the blockchain RID:

    Execute the following command, replacing the placeholder values as needed:

    yarn setBlockchainRid:bridge --network bsc_testnet --address 0x7EE9dfbDF18c609a5e1AB0180c8A2ec6D473E093 --blockchain-rid AB889D51EECC3A063B2430084BB6EA5EC3A1EAB866AC62CAA553D8758933CADA

This command updates the token bridge contract with the specified blockchain RID, enabling it to interact with the designated blockchain.

Configure the frontend app

Copy and update environment variables

Copy the environment configuration file for the bridge frontend app:

cp ./bridgefrontend/.env.local ./bridgefrontend/.env

Update the following variables in the .env file:

  • VITE_BRID: Set this to the blockchain RID obtained from your event receiver (e.g., 6613EA1B36823AA67D65C6104BB93A789089D0E568939FD6CBACCE6AFF1D0859).
  • VITE_BRIDGE_ADDRESS: Set this to the deployed token bridge contract address (e.g., 0x7EE9dfbDF18c609a5e1AB0180c8A2ec6D473E093).
  • VITE_TOKEN_ADDRESS: Set this to the deployed token contract address (e.g., 0x22Ea9bF66Ee38E39A333773e584f37216136700A).

Run the bridge frontend app

Navigate to the bridgefrontend directory, install the dependencies, and start the app:

cd ./bridgefrontend
pnpm install
pnpm run dev

Now you’re all set up to use the bridge demo app.