logoAcademy

Understanding the Flow

Learn how requests for random words flow across chains using ICM.

This section explains how random words are requested and fulfilled using Chainlink VRF across two different blockchains through Interchain Messaging (ICM). The entire process involves several key components: the decentralized application (DApp), CrossChainVRFConsumer, CrossChainVRFWrapper, and TeleporterMessenger.

Let’s walk through the flow step by step:

DApp Submits Request for Random Words

The DApp, running on an L1 without direct Chainlink support, initiates a request for verifiable randomness by interacting with the CrossChainVRFConsumer contract deployed on its chain.

CrossChainVRFConsumer Sends Cross-Chain Message

Once the DApp submits the request, the CrossChainVRFConsumer prepares a message containing the necessary VRF request parameters (such as keyHash, request confirmations, gas limit, etc.). This message is sent across chains via the TeleporterMessenger to the CrossChainVRFWrapper on the Chainlink-supported network (e.g., Fuji).

TeleporterMessenger Receives Message & Calls CrossChainVRFWrapper

  1. On the Chainlink-supported network, the TeleporterMessenger receives the cross-chain message sent by the CrossChainVRFConsumer. It passes the message to the CrossChainVRFWrapper, which is authorized to handle VRF requests.
  2. The CrossChainVRFWrapper contract, deployed on the supported network, sends the request to Chainlink VRF for random words, using the parameters received in the message (e.g., subscription ID, callback gas limit, etc.).
  1. The Chainlink VRF fulfills the request and returns the random words to the CrossChainVRFWrapper contract by invoking its callback function.
  2. Once the random words are received, the CrossChainVRFWrapper encodes the fulfilled random words and sends them back as a cross-chain message to the CrossChainVRFConsumer on the original L1.

TeleporterMessenger Returns Random Words to CrossChainVRFConsumer

The TeleporterMessenger on the original L1 receives the message containing the random words and passes it to the CrossChainVRFConsumer.

CrossChainVRFConsumer Returns Random Words to the DApp

Finally, the CrossChainVRFConsumer processes the random words and sends them to the DApp that originally requested them, completing the flow.

This end-to-end process demonstrates how decentralized applications on unsupported L1 networks can request verifiable randomness from Chainlink VRF, leveraging ICM to handle cross-chain communication.

On this page