Request Random Words
Learn how to request random words using CrossChainVRFConsumer.
In this section, you will learn how to request random words from Chainlink VRF using both the CrossChainVRFConsumer
contracts.
Authorize an Address to Request Random Words
After deploying the CrossChainVRFWrapper
contract, the first step is to authorize an address to make requests for random words. This ensures that only specific addresses linked to a subscription can request VRF.
- Use the
addAuthorizedAddress
function to authorize a specific address with a given subscription ID. This step allows the address to make random word requests through the wrapper.
Request Random Words from CrossChainVRFConsumer
Once the address is authorized, the next step is to send a request for random words from the CrossChainVRFConsumer
contract on the unsupported L1. This request is then sent to the CrossChainVRFWrapper
via a cross-chain message.
Replace the placeholders with:
<KEY_HASH>
: The VRF key hash used for random word generation.<CONFIRMATIONS>
: Number of confirmations required for the request.<GAS_LIMIT>
: The gas limit for the VRF callback function.<NUM_WORDS>
: The number of random words requested.<NATIVE_PAYMENT>
: Indicates whether the payment will be made in the native token.<REQUIRED_GAS_LIMIT>
: The gas limit required for the cross-chain message to be processed.