Skip to main content

Hyperlane Bridge


This section will guide you through the process of interacting with the Hyperlane Bridge on the Eclipse Devnet

What does the Hyperlane Bridge do?

  • The Hyperlane bridge essentially allows us to transfer tokens from the Solana network to the Eclipse network and vice versa. The goal is to provide fast finality bridging between the Eclipse mainnet and non-Ethereum chains in general. This was achieved by deploying a Hyperlane mailbox contract for the SVM. You can read more about that here

Mailbox Contract

  • The mailbox contract is the reason we are able to perform interchain operations, therefore we must interact with it to write smart contracts directly for the bridge. If you want to test a UI for the current mailbox deployment you can do so here
  • Assuming you have already setup Rust, Solana and switched to the Eclipse Devnet using our RPC, lets move to wrting the smart contract.

Interacting with the mailbox contract

  • For Hyperlane to deliver a message to our smart contract we need to implement a handle function. This function will be called by the mailbox.

Writing the smart contract:

Parsing instruction data:

  • Here we are sending the instruction data and setting up the send message function
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
match instruction_data.get(0) {
Some(&0) => {
let accounts_iter = &mut accounts.iter();
let sender_account = next_account_info(accounts_iter)?;
let recipient_account = next_account_info(accounts_iter)?;
let message_data = &instruction_data[1..];
  • Now we call the send message function
  • Here we can call the receive message function
  • This goes inside the main match block
Some(&1) =>{
let accounts_iter = &mut accounts.iter();
let recipient_account = next_account_info(accounts_iter)?;
mailbox::instruction::receive_message(program_id, recipient_account)?;
_ => return Err(solana_program::program_error::ProgramError::InvalidInstructionData),

Hyperlane CLI

  • As of now we can use the Hyperlane CLI to get a better understanding of how the deployments work and how to interact with them. The CLI can also be used to test sending and receiving messages.