Skip to content

lexaisnotdead/Arbitrary-Message-Bridge

Repository files navigation

AMB - Arbitrary Message Bridge

The Arbitrary Message Bridge (AMB) is designed to relay any data between two EVM-based chains. The user encodes data in the form of an arbitrary method call, which can also include or exclude parameters. This information, along with the target contract address and foreign chain ID, is passed to the Sender contract. As soon as data are relayed from chain A to chain B by the validators, the user can call the executeMessage function in the Receiver contract on side B to execute the encoded method of the target contract. Oracles can validate messages by listening to Sender events or using data stored on-chain in the Sender contract.

Features

  • sendMessage: The main user function of the Sender contract. Allows the user to send an encoded message to the provided chain.
  • executeMessage: The main user function of the Receiver contract. Allows the user to execute an encoded message if it has been validated by oracles.

Use cases

  • transfer digital assets between two chains
  • trigger a method in one chain after some contract invocation in another chain
  • propagate tokens prices to another chain
  • synchronize contracts states between two chains

Setup

  1. Clone the repository and navigate to the project directory:
git clone https://github.com/lexaisnotdead/Arbitrary-Message-Bridge.git
cd ./Arbitrary-Message-Bridge
  1. Install the project dependencies:
npm install
  1. Create a new .env file in the project directory with the following variables:
INFURA_API_KEY = <your_infura_project_id>
PRIVATE_KEY = <your_private_key>
ETHERSCAN_API_KEY = <your_etherscan_api_key>
  1. create a new state.json file according to the example from state-example.json.

Usage

To run the tests, simply execute the following command:

npx hardhat test

To deploy the contracts to a local network, execute the following commands:

npx hardhat run scripts/deploy-sender.js --network localhost
npx hardhat run scripts/deploy-receiver.js --network localhost

Replace localhost with the name of the network you want to deploy to (e.g. goerli, mainnet, etc.) and make sure you have the corresponding configuration in the hardhat.config.js file.

Links

Links to the verified contracts in the Goerli network:

Sender V1 proxy contract

Sender V1 implementation contract

Receiver V1 proxy contract

Receiver V1 implementation contract

Sender V2 proxy contract

Sender V2 implementation contract

Receiver V2 proxy contract

Receiver V2 implementation contract

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors