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.
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.
- 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
- Clone the repository and navigate to the project directory:
git clone https://github.com/lexaisnotdead/Arbitrary-Message-Bridge.git
cd ./Arbitrary-Message-Bridge- Install the project dependencies:
npm install- Create a new
.envfile 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>- create a new
state.jsonfile according to the example fromstate-example.json.
To run the tests, simply execute the following command:
npx hardhat testTo 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 localhostReplace 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 to the verified contracts in the Goerli network:
Sender V1 implementation contract
Receiver V1 implementation contract