Rayls DocsRayls Custody API
Rayls Docs

Send Cross Subnet Arbitrary Messages

This feature enables secure message delivery between different Rayls Nodes. This feature allows them to talk to each other — sending messages, updates, or notifications back and forth — so they stay in sync and work together smoothly.
This feature is crucial for apps that operate across multiple blockchains. It keeps different versions of the app in sync and allows data to flow smoothly between them — whether it's a notification, a setting change, or an update.

Without it, apps would be isolated on their own chains. With it, they can act like one unified system, no matter where they're running.
This feature supports:

  • Broadcasting messages - There are situations where a message needs to go to several or all chains at once;
  • Send multiple messages at once - one transaction might need to send multiple pieces of information to multiple destination chains;
  • It performs well at scale and can send up to 60 messages in a row;

How to use

To send messages, you interact with the ArbitraryMessage smart contract on Chain A using one of its messaging functions. Each function supports a different use case depending on how many messages you want to send and to whom.

  1. Send a Single Message to One Chain

Scenario:

Send one simple message from Chain A to Chain B.

 const tx = await arbitraryMessageA.connect(signerA).send1Message(messageA, chainIdB, { gasLimit: 5000000 });

Outcome:
Chain B will receive the message - Use when you just need to update or notify a single chain.


  1. Send Three Messages in One Transaction (to the Same Chain)

Scenario:

Send three distinct messages all at once to the same chain.

const tx = await arbitraryMessageA.connect(signerA).send3Messages(messageB, messageC, messageD, chainIdB, { gasLimit: 5000000 });

Outcome:
Chain B will receive the messages - Use this for grouped updates (e.g., multiple settings or fields).


  1. Send Three Different Messages in One Transaction (to the different Chains)
    Scenario:
    Send one message each to three different chains.
const tx = await arbitraryMessageA.connect(signerA).send3MessagesToDifferentChainIds(messageB, messageC, messageD, chainIdB, chainIdC, chainIdD, { gasLimit: 5000000 });

Outcome:
The RNs selected will receive the messages - Use when different chains each need a different piece of information.


  1. Send the Same Message to Multiple Chains
    Scenario:
    Send three distinct messages all at once to the same chain.
 const tx = await arbitraryMessageA.connect(signerA).sendToMultipleParticipants(messageForMultiple, chainIds, { gasLimit: 5000000 });

Outcome:
The RNs selected will receive the message - Use for targeted updates — like notifying multiple teams, not everyone.

  1. Send the Same Message to All Chains
    Scenario:
    Broadcast a single message to every connected RN.
const tx = await arbitraryMessageA.connect(signerA).sendToAllParticipants(messageForAll, { gasLimit: 5000000 });

Outcome:
All the RNs connected to the Subnet will receive the message - Use for targeted updates — like notifying multiple teams, not everyone.