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:
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.
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.
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.
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.
- Deploy and initialize the light client contract on NEAR Testnet.
- Deploy and initialize the prover contract on NEAR Testnet.
- Start the relayer from Calimero to NEAR Testnet and keep it running.
- Deploy and initialize the light client contract on Calimero.
- Deploy and initialize the prover contract on Calimero.
- Start the relayer from NEAR Testnet to Calimero and keep it running.
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.
- Deploy and initialize the ft_connector on NEAR Testnet.
- Deploy and initialize the ft_connector on Calimero.
- Call the set_locker function on the ft_connector contract on NEAR Testnet and also call it on Calimero.
- Start the bridge service and keep it running.
Transferring tokens from the source chain to the destination chain involves the following steps:
- 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.)
- 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.
- 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.