Skip to main content

Prerequisite for using the bridge

Before utilizing the bridge for token transfers and cross-shard calls, there are certain prerequisites that need to be fulfilled. Here are the necessary requirements:

  1. Running Calimero Shard: Ensure that a Calimero shard is up and running. If you wish to set up your own Calimero shard, you can contact us via email or by filling out the contact form.

  2. Deployment of Contracts: Deploy the required contracts on both the NEAR and Calimero chains. These contracts include the light client contract, prover contract, FT connectors, NFT connectors, and cross-shard call connectors.

  3. Relayers: Run a relayer from NEAR to Calimero and another relayer from Calimero to NEAR. These relayers are responsible for relaying relevant blocks between the two chains.

  4. Bridge Service: The bridge service should be running to monitor events in real-time on both NEAR and Calimero. It ensures the smooth operation of token transfers and cross-shard calls.

caution

When bridging tokens, it is crucial to possess the Account ID on the destination chain before initiating the bridge. Failure to do so may result in asset loss. Obtain the destination Account ID prior to the bridging process.

To set up a bridge between NEAR Testnet and a Calimero shard manually, follow these steps. Alternatively, you can use the Calimero Console tool for automated setup.

Install Bridge

  1. Deploy and initialize the light client contract on NEAR Testnet.
  2. Deploy and initialize the prover contract on NEAR Testnet.
  3. Start the relayer from Calimero to NEAR Testnet and keep it running.
  4. Deploy and initialize the light client contract on Calimero.
  5. Deploy and initialize the prover contract on Calimero.
  6. Start the relayer from NEAR Testnet to Calimero and keep it running.
info

Please note that steps (1-3) and (4-6) can be completed in parallel.

Deploy the Connectors

To create the FT connectors (fungible token connectors), follow these steps. Similar steps can be followed for NFT connectors and cross-shard call connectors.

  1. Deploy and initialize the ft_connector on NEAR Testnet.
  2. Deploy and initialize the ft_connector on Calimero.
  3. Call the set_locker function on the ft_connector contract on NEAR Testnet and also call it on Calimero.
  4. Start the bridge service and keep it running.

Transferring Tokens

Transferring tokens from the source chain to the destination chain involves the following steps:

  1. Ensure that the fungible token on the source chain is registered with the ft_connector contract account ID. Note that some fungible tokens require calling the storage_deposit function before interacting with the specific token contract. This step is known as registering the account with the ft contract. (Note: Not all tokens require this step; for example, USN does not require it.)
  2. Once the ft_connector is registered with the fungible token, any user can initiate token transfers from the source chain to the destination chain and withdraw tokens back from the destination chain to the source chain.
  3. Follow the specific steps described in the Fungible Token Connector section to initiate a transfer and complete the token transfer process.

By following these steps, you can successfully run a bridge between NEAR Testnet and a Calimero shard, enabling the transfer of tokens and facilitating interoperability between the two chains.