Creation and Deployment of VRF-Consumer Contract

  1. For this demonstration, utilize the vrf_subscription_consumer_xdc_apothem.sol contract. This contract imports dependencies including VRFConsumerBaseV2.sol, VRFCoordinatorV2Interface.sol, and ConfirmedOwner.sol.

  2. The contract incorporates preconfigured values for requisite request parameters such as vrfCoordinator address, gas lane keyHash, callbackGasLimit, requestConfirmations, and the number of random words, numWords. For this scenario, specify only the subscriptionId during contract deployment.

  3. Open and copy the vrf_subscription_consumer_xdc_apothem.sol contract to remix

  4. Click the Deploy button to initiate on-chain deployment of your contract. MetaMask prompts confirmation of the transaction.

  5. Upon contract deployment, copy the contract address from the Deployed Contracts list in Remix. Subsequently, add this address as an approved consuming contract on your subscription account before requesting randomness from VRF.

  6. Access the Subscription Manager and select the ID of your new subscription under the My Subscriptions list to view subscription details.

  7. Under the Consumers section, click Add consumer.

  8. Input the address of your recently deployed consuming contract and click Add consumer. MetaMask prompts confirmation of the transaction.

  9. Deployment and Approval of Example Contract

Your example contract is now deployed and approved for utilization of your subscription balance to facilitate VRF requests. Next, proceed to request random values from Plugin VRF.

Last updated