paint-brush
How to Bridge a Rootstock Token to BNB Smart Chain Using Hyperlane Warp Routesby@induction
232 reads

How to Bridge a Rootstock Token to BNB Smart Chain Using Hyperlane Warp Routes

by Vision NPDecember 1st, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The Hyperlane protocol is designed to allow secure, scalable, and decentralized communication between different blockchains. The protocol utilizes [Warp Routes], a feature that enables efficient token transfer between supported chains. This article is inspired by an excellent tutorial from Rootstock's official documentation: [How to Run Hyperlane Bridge on Rootstock]
featured image - How to Bridge a Rootstock Token to BNB Smart Chain Using Hyperlane Warp Routes
Vision NP HackerNoon profile picture

Bridging between different blockchains is a highly demanded feature in the decentralized finance (DeFi) ecosystem. It helps to enhance interoperability and asset transfers. The Hyperlane is that kind of a protocol that is designed to allow secure, scalable, and decentralized communication between different blockchains.


The Hyperlane provides a cool framework for cross-chain messaging, which includes a powerful tool for bridging assets and tokens across chains. It is designed to be chain-agnostic and supports bridging between chains such as Binance Smart Chain (BSC) and Rootstock (RSK), among others. The protocol utilizes Warp Routes, a feature that enables efficient token transfer between supported chains. The key benefits of integrating this route are enhanced scalability and reduced transaction costs.


Warp Routes allow you to bridge tokens across blockchains with enhanced efficiency like Rootstock to BNB Smart chain (BSC) in our case. Warp Routes optimize the cross-chain messaging process. The “Warp Routes” assist in transferring tokens between chains with less congestion and faster execution.


This article is inspired by an excellent tutorial from Rootstock's official documentation: How to Run Hyperlane Bridge on Rootstock, which guides users through the process of deploying Hyperlane's core contracts on Rootstock using the Hyperlane CLI. Once you are capable of setting up the core infrastructure using the Rootstock official tutorial, it is not so hard for you to bridge a token from the Binance Smart Chain (BSC) to Rootstock using Warp Routes.


So, let’s get started with this revolutionizing tech testing, development, and deployment.


📥Prerequisites

Before you start, make sure to have the following are ready:

  1. Hyperlane CLI installed: Follow the Hyperlane CLI Installation Guide
  2. A private key of your MetaMask wallet for transaction signing (preferably stored in a .env file).
  3. Node.js v20 or later installed on your machine.

📥Hyperlane Warp Route Deployment

Run the following commands:

npm install -g @hyperlane-xyz/cli
hyperlane --version

It will install the @hyperlane-xyz/cli globally. If you prefer to install it in a particular directory, you might use

npm i @hyperlane-xyz/cli --save

📥Initialize Deployment Configuration

Now it’s time to generate a deployment configuration for the Warp Route:

hyperlane warp init


During the prompt in the terminal, fill in the following sample details. Remember, you can prefer to choose other EVM-based networks like BSC.

Creating a new warp route deployment config...

? Enter the desired owner address: 0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C (Write the owner address)

? Select network type Testnet

? Select chains to connect bsctestnet, rootstocktestnet (Press the arrow button, and spot the correct network in the list than click “Space” button, and then “Enter” to select.)

? Is this chain selection correct?: bsctestnet, rootstocktestnet yes


bsctestnet: Configuring warp route...


? Use an existing Proxy Admin contract for the warp route deployment on chain "bsctestnet"? yes

? Please enter the address of the Proxy Admin contract to be used on chain "bsctestnet": 0xb12282d2E838Aa5f2A4F9Ee5f624a77b7199A078 (Use the pre-deployed contract from any existing chains from the registry/CLI better don’t create a new mailbox)

? Do you want to use a trusted ISM for warp route? yes

? Select bsctestnet's token type native


rootstocktestnet: Configuring warp route...

? Use an existing Proxy Admin contract for the warp route deployment on chain "rootstocktestnet"? yes

? Please enter the address of the Proxy Admin contract to be used on chain "rootstocktestnet": 0x2B88eFFe0C9182bF83C7353D53689C830db45800

? Do you want to use a trusted ISM for warp route? yes

? Select rootstocktestnet's token type native

Warp Route config is valid, writing to file ./configs/warp-route-deployment.yaml:


Now you can find the configs file in ./configs/warp-route-deployment.yaml which looks like as follows:

  bsctestnet:
      isNft: false
      type: native
      owner: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
      mailbox: "0xF9F6F5646F478d5ab4e20B0F910C92F1CCC9Cc6D"
      interchainSecurityModule:
        type: staticAggregationIsm
        modules:
          - type: trustedRelayerIsm
            relayer: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
          - owner: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
            type: defaultFallbackRoutingIsm
            domains: {}
        threshold: 1
      proxyAdmin:
        owner: "0xfaD1C94469700833717Fa8a3017278BC1cA8031C"
        address: "0xb12282d2E838Aa5f2A4F9Ee5f624a77b7199A078"
    rootstocktestnet:
      isNft: false
      type: native
      owner: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
      mailbox: "0xCfA3E807DEF506Db480328cB975fC9108eb59e52"
      interchainSecurityModule:
        type: staticAggregationIsm
        modules:
          - type: trustedRelayerIsm
            relayer: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
          - owner: "0x3C5A83f9ca6789DceFdb53e6A4073332f80ed07C"
            type: defaultFallbackRoutingIsm
            domains: {}
        threshold: 1
      proxyAdmin:
        owner: "0xd624E015A308d7917F07424bb4985a024af1188a"
        address: "0x2B88eFFe0C9182bF83C7353D53689C830db45800"

✅ Successfully created new warp route deployment config.


Now, you can review the warp-route-deployment.yamlfile and manually configure it if any error persists while deploying the Wrap route.

📥Chain Metadata Configuration

If Hyperlane does not have pre-configured metadata for the chains for your choices, you can initialize it manually first,


List Known Chains:

hyperlane registry list


Create Chain Metadata Config:

hyperlane registry init


During the prompt in the terminal, adjust the setup as shown in the following figure:

Figure 1. Prompt in the terminal while initializing hyperlane registry

After a successful operation, you will see something like the following in the terminal:

 chainId: 31
    displayName: rootstocktestnet
    domainId: 31
    isTestnet: true
    name: rsk
    nativeToken:
      decimals: 18
      name: Testnet Rootstock Smart Bitcoin
      symbol: tRBTC
    protocol: ethereum
    rpcUrls:
      - http: https://public-node.testnet.rsk.co


📥Deploy the Warp Route

Run the following command to deploy the Warp Route:

hyperlane warp deploy

You will see the output in the terminal like as follow during the deployment process:

Figure 2.The hyperlane warp deploy output in the terminal


You will be asked to enter your wallet’s private key during the prompt and provide it. It takes a few minutes to conclude the deployment process. Make sure to have sufficient tRBTC and testnet BNB for your address from these two official sources Rootstock faucet and BNB Smart Chain Testnet Faucet.


Network might exhibit excessively high fees while deploying so, you might include the gasLimit parameter in transactionOverrides manually, if it is not automatically provided by the CLI, by modifying the metadata.yaml file located at .hyperlane/chains. Also, prefer official documentation here.

Note:- For automation:

Add your private key to the .env file: HYP_KEY=your_private_key and export the key using the code:

export HYP_KEY=$(cat .env | grep HYP_KEY | cut -d '=' -f2)


During deployment, two files will be generated:

otherchain-yourchain-addresses.yaml: It contains contract addresses for deployed Warp Routes.

otherchain-yourchain-config.yaml: it contains CLI configurations for the bridge.


These files are stored in the default Hyperlane directory: .hyperlane/deployments/warp_routes/ You can check to further investigate.


📥Test the Bridge

Now you can send test transfer to test transferring tokens between chains:

hyperlane warp send --relay --symbol tRBTC
  • --relay: Relays the message to the destination chain.
  • Make sure both source and destination chains are configured correctly in chain-config.yaml.


📥Run Relayer

To test token transfers locally, start the relayer:

hyperlane relayer --symbol tRBTC


If you experience any difficulties, you might prefer this official documentation here: https://docs.hyperlane.xyz/docs/guides/deploy-warp-route


Alright, this is for the token transfer from Rootstock to the BNB Smart chain (BSC). In my next tutorial, we will be focused on production-ready attractive Bridge UI based on the deployed result. After the token has been bridged to the BNB Smart Chain (BSC) from Rootstock, you can verify the transaction and check the balance of the token on the BNB Smart Chain(BSC). You can use MetaMask or any compatible wallet to check the token's balance on the BNB Smart Chain (BSC). Ensure that the contract address is correctly registered and that the token shows up in your wallet.


📥Conclusion

The Rootstock’s unique feature has made the thing possible to bridge a BSC token or other network’s tokens to Rootstock through Hyperlane Warp Routes. It is a systematic process that utilizes the power of decentralized messaging and cross-chain communication. Once you can set up the Hyperlane core contracts and utilize Warp Routes, you can efficiently bridge assets across different blockchains like Binance Smart Chain and Rootstock which is an excellent innovation in the crypto sphere.


So many projects are still struggling to have interoperability features, but Rootstock as being attached to the Bitcoin blockchain with a unique two-way peg feature, has opened the door for the developers to come up with new ideas. The tutorial provided by Rootstock’s documentation, combined with the steps outlined here, helps you to bridge tokens seamlessly between different blockchain ecosystems. We can create the best-looking Bridge UI for a better representation of the dApp in the next tutorials. Anyway, as the demand for cross-chain interactions grows, solutions like Hyperlane provide the scalability, security, and ease of use necessary for the next generation of decentralized applications.