Two-Way Messaging Configuration
Learn how to configure a relayer for multiple L1s
Two-Way Messaging Configuration
In this section, you’ll learn how to configure a relayer to support two-way messaging between multiple Layer 1 blockchains (L1s). By extending your existing configuration, you can enable the relayer to handle communication in both directions, eliminating the need to run multiple relayers.
Accessing the Relayer Configuration File
The relayer configuration is supplied as a JSON file. To open the configuration file automatically created by the Avalanche-CLI, run the following command:
Alternatively, navigate to the directory ~/.avalanche-cli/runs/
and locate the relayer configuration file for your network.
Understanding the Existing Configuration
Assuming you have a configuration as described in the Relayer Configuration section, your current configuration should look similar to the following:
Updating the Configuration for Two-Way Communication
To enable two-way communication between L1s, you need to extend the configuration to include both blockchains in the source-blockchains and destination-blockchains arrays.
Updated Configuration:
Explanation of Changes
By adding both blockchains to the source-blockchains and destination-blockchains arrays, the relayer is configured to:
- Listen for messages on both blockchains.
- Relay messages to the opposite blockchain.
This setup enables two-way communication between the blockchains using a single relayer instance.
Important Considerations
- Private Keys: Ensure that the account-private-key field contains the private key for the respective blockchain. This key is used to sign transactions when relaying messages.
- Funding: The relaxyer account must have sufficient funds on both L1s to cover transaction fees.
Next Steps
After updating the configuration file:
- Save the changes.
- Restart the relayer to apply the new configuration.
- Test the two-way communication by sending messages between the blockchains.