Skip to content

wormhole-foundation/demo-wormhole-messaging

Repository files navigation

Demo Cross-Chain Messaging with Wormhole

This project demonstrates how to send and receive cross-chain messages using the Wormhole protocol, specifically between Avalanche Fuji and Celo Alfajores TestNets. The repository includes automated scripts for deploying contracts and sending messages across these chains.

Features

  • Deploy smart contracts on Avalanche Fuji and Celo Alfajores TestNets
  • Automatically manage contract addresses
  • Send a cross-chain message from one chain to another using Wormhole

Prerequisites

PRIVATE_KEY=0x...

The chains.json file requires the details of the source and target chains. For a complete list of contract addresses needed to populate this file, visit the contract addresses page from the Wormhole Documentation. In this project, we are using Avalanche and Celo as default.

Quickstart

1. Clone the repository:

git clone https://github.com/wormhole-foundation/demo-wormhole-messaging.git

2. Install dependencies:

npm install
forge install

3. Compile contracts:

forge build

4. Run Tests:

Before deploying contracts, it's recommended to run the tests to ensure everything is functioning correctly. Run:

forge test

The expected output should include passing results for all test cases, with outputs similar to:

Ran 3 tests for test/CrossChainMessagingTest.sol:CrossChainMessagingTest
[PASS] testDeployment() (gas: 13011)
[PASS] testReceiveMessage() (gas: 18114)
[PASS] testSendMessage() (gas: 21029)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 7.53ms (3.55ms CPU time)

Ran 1 test suite in 112.75ms (7.53ms CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)

5. Deploy contracts:

Deploy the sender contract on Avalanche Fuji:

npm run deploy:sender
  • You may see the respective contract deployed on the Fuji Explorer

Deploy the receiver contract on Celo Alfajores:

npm run deploy:receiver

6. Send Cross-Chain Message:

Send a message from Avalanche Fuji to Celo Alfajores:

npm run send:message

How It Works

The project uses two smart contracts:

  • MessageSender.sol (Avalanche Fuji) - sends a message to the target chain
  • MessageReceiver.sol (Celo Alfajores) - receives the message and logs it

The deployment scripts automatically store the contract addresses in deployedContracts.json for easy reuse.

Project Structure

  • script/ - deployment and interaction scripts
  • deploy-config/ - chain configuration and deployed contract addresses
  • out/ - compiled contract artifacts
  • lib/ - external dependencies (auto-managed by Foundry)
  • test/ - unit tests for smart contracts

Resources

The Wormhole documentation tutorial provides a detailed, step-by-step guide for setting up and running this repository.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published