Run Hyperlane Bridge on Rootstock
Hyperlane is the first universal and permissionless interoperability layer built for the modular blockchain stack.
This tutorial guides you through the process of setting up Hyperlane on the Rootstock blockchain to create seamless asset bridging between Rootstock and other compatible chains. You will learn how to install Hyperlane, configure custom chains, deploy contracts, and run validator and relayer nodes.
Some example dApps that can be developed using Hyperlane bridge:
- Warp Routes, which allow native and ERC20 tokens to move seamlessly across chains such (e.g. Sending ERC20 tokens to/from Rootstock to BNB chian)
- Interchain accounts, which allows an account on one chain (e.g. a DAO) to make smart contract calls on remote chains
- Interchain queries, which allows an account on one chain such as Rootstock to make view (read calls) on remote chains such as BNB chain or any other EVM compatible chain
Hyperlane CLI
The Hyperlane CLI is the official command-line tool for deploying Hyperlane contracts to new chains. It also includes utilities for interacting with deployed contracts and registries.
Both Rootstock testnet and mainnet are integrated in the CLI via the Hyperlane registry.
To get started, install the hyperlane cli using npm.
Installation
There are two options for installing the Hyperlane CLI:
-
Global installaton
Use
-g
flag to globally install Hyperlane cli and access anywhere in your terminalnpm i @hyperlane-xyz/cli -g
-
Install within a directory
In the terminal, make a directory to install Hyperlane cli:
mkdir hyperlane_cli
cd hyperlane_cli
npm i @hyperlane-xyz/cli --saveThis will install Hyperlane cli within the
hyperlane_cli
directory insidenode_modules
. This is the most recommended way to use Hyperlane cli. Now test the installation by running following command insidehyperlane_cli
directory:npx hyperlane --version
If you installed Hyperlane CLI within a directory using the second option, you'll need to use npx hyperlane
instead of just hyperlane
in your terminal. This ensures that npx can locate the CLI within your local node_modules directory. If you installed Hyperlane CLI globally, you can use hyperlane
directly.
Registry
Let’s create a custom chain config, run:
// Use `npx hyperlane` in case of local installation
hyperlane registry init
Output:
# yaml-language-server: $schema=../schema.json
name: rootstocktestnet
displayName: rootstocktestnet
chainId: 31
domainId: 31
protocol: ethereum
rpcUrls:
- http: https://public-node.testnet.rsk.co
nativeToken:
symbol: ETH
name: Ether
decimals: 18
transactionOverrides:
gasLimit: 6800000
- Under $HOME/.hyperlane/chains you will find a new folder named with your custom chain’s name, and a file named metadata.yaml within that folder.
- On Mac, use the following commands to view the folder.
ls $HOME/.hyperlane/chains
cd $HOME/.hyperlane/chains/rootstocktestnet
Open the folder in your code editor to view the file: metadata.yml
.
Append transactionOverrides
gasLimit if it's not automatically added by cli by editing the metadata.yaml file at: $HOME/.hyperlane/chains
Reference: https://docs.hyperlane.xyz/docs/deploy-hyperlane#1-registry
Core init
Next, let’s configure, deploy and test your custom chain’s core contracts.
Initialize configuration
To initialize, set the private key or seed phrase of your funded deployer address to HYP_KEY in a local environment variable. For example: export HYP_KEY=<YOUR_PRIVATE_KEY>
.
From the same terminal instance, run:
// Use `npx hyperlane` in case of local installation
hyperlane core init
Output
Hyperlane Core Configure
------------------------
Creating a new core deployment config...
? Detected owner address as 0xd624E015A308d7917F07424bb4985a024af1188a from signer, is this correct? yes
Creating trustedRelayerIsm...
Created trustedRelayerIsm!
Creating merkleTreeHook...
Created merkleTreeHook!
Creating protocolFee...
Created protocolFee!
Core config is valid, writing to file ./configs/core-config.yaml:
owner: "0xd624E015A308d7917F07424bb4985a024af1188a"
defaultIsm:
type: trustedRelayerIsm
relayer: "0xd624E015A308d7917F07424bb4985a024af1188a"
defaultHook:
type: merkleTreeHook
requiredHook:
owner: "0xd624E015A308d7917F07424bb4985a024af1188a"
type: protocolFee
beneficiary: "0xd624E015A308d7917F07424bb4985a024af1188a"
maxProtocolFee: "100000000000000000"
protocolFee: "0"
✅ Successfully created new core deployment config.
Reference: https://docs.hyperlane.xyz/docs/deploy-hyperlane#2-core
Deploy contracts
To deploy contracts, run:
// Use `npx hyperlane` in case of local installation
hyperlane core deploy
Output:
hyperlane core deploy
Hyperlane CLI
{"level":30,"time":1726741403674,"pid":51011,"msg":"Your CLI version: 5.1.2, latest version: 5.2.0"}
? Please enter private key or use the HYP_KEY environment variable.
Hyperlane Core deployment
------------------------------------------------
? Select network type Testnet
? Select chain to connect: rootstocktestnet
? Do you want to use an API key to verify on this (rootstocktestnet) chain's block explorer no
Deployment plan
===============
Transaction signer and owner of new contracts: 0xA0365b08A56c75701415610Bf49B30DbfA285ac4
Deploying core contracts to network: rootstocktestnet
┌────────────────────────┬───────────────────── ─────────────────┐
│ (index) │ Values │
├────────────────────────┼──────────────────────────────────────┤
│ Name │ 'rootstocktestnet' │
│ Display Name │ 'rootstocktestnet' │
│ Chain ID │ 31 │
│ Domain ID │ 31 │
│ Protocol │ 'ethereum' │
│ JSON RPC URL │ 'https://public-node.testnet.rsk.co' │