For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integration Guide

1. Deploy Your Own VRFConsumerV2 Contract

The deployment parameters can be obtained from our official website: 🔗 APRO VRF Portal

Supported Chains

Bitlayer

Steps to Deploy

  • Deploy your own VRFConsumerV2 contract

First, copy the contract code as follows to your local machine File 1 of 4 : LinkTokenInterface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface LinkTokenInterface {
  function allowance(address owner, address spender) external view returns (uint256 remaining);

  function approve(address spender, uint256 value) external returns (bool success);

  function balanceOf(address owner) external view returns (uint256 balance);

  function decimals() external view returns (uint8 decimalPlaces);

  function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);

  function increaseApproval(address spender, uint256 subtractedValue) external;

  function name() external view returns (string memory tokenName);

  function symbol() external view returns (string memory tokenSymbol);

  function totalSupply() external view returns (uint256 totalTokensIssued);

  function transfer(address to, uint256 value) external returns (bool success);

  function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);

  function transferFrom(address from, address to, uint256 value) external returns (bool success);
}

File 2 of 4 : VRFCoordinatorV2Interface.sol

File 3 of 4 : VRFConsumerBaseV2.sol

File 4 of 4 : VRFConsumerV2.sol

  • Open the contract code using Remix, as shown below.

  • Switch to the compilation tab, select the compilation version, and compile the contract code.

  • Switch to the deployment tab, select the compilation version, and link your wallet address

  • In step 7 shown in the image above, enter the VRF Coordinator V2 address and link(Valueless Token) address and then click "transact" Finally,as shown in the image, you can copy your VRFConsumerV2 contract address in step nine, which will be used later.


2. Create a Subscription

  1. Open the VRF Subscription Manager: 🔗 Subscription Manager

  2. Connect your wallet (top-right corner) and click "Create Subscription".

  3. The Admin Address field is auto-filled with your connected wallet address.

  4. Once created, an alert will confirm the subscription, and you'll be redirected to the dashboard.

  5. Locate your Subscription ID in the "My Subscriptions" list.


3. Add a Consumer

  1. On the subscription details page, click "Add Consumer".

  2. Enter the address of your consuming contract and confirm the addition.

  3. Approve the transaction in MetaMask or your wallet extension.


4. Fund Your Subscription

To fund your subscription, provide:

  • Your wallet address

  • Your Subscription ID

Then, contact us via: 📧 Email: bd@apro.com 💬 Telegram: Head of Business Development


5. Request Randomness

Call the requestRandomness function in the VRFConsumerV2 contract

Example Input

Retrieve Randomness

Call the s_randomWords function in the VRFConsumerV2 contract to get the random number.

  • Enter the index (starting from 0, max = numWords - 1).


6. VRF Information

6.1 Bitlayer Mainnet

Contracts

Contracts Description
Contract Address

Valueless Token

0x48Ee5E7E27A5058eBf74c8Bb6A2DD1E6176A84a1

BlockHashStore

0xd3fBd0Cdb7774617fCCa347804Ea48277d586c6A

VRF Coordinator V2

0x8571C322bf9FC9dDD40635300cC534693fef4067

VRF KeyHash Info

VRF KeyHash Description
Contract Address

KeyHash 1 (Max Gas: 5 GWEI)

0xe568bd3aa35ca9857f68102223a2313ead8ad257b322306a2649f2dff5fc3235

KeyHash 2 (Max Gas: 10 GWEI)

0x86af5b5dd69ca4845538ca99ad0087c917fed2475793b4c2c9237556e719c2ca

KeyHash 3 (Max Gas: 15 GWEI)

0xbdacf5b71bc9b737f8ffcf7612bea13114b1923c2fe6aa5ca0a7deb9a318f22c

6.2 Bitlayer Testnet

Contracts

Contracts Description
Contract Address

Valueless Token

0xF424cAA15eF7F8524bF55bD838935A25cDf1caae

BlockHashStore

0x70df6E187188e10A6552445Be86C73ce2168a452

VRF Coordinator V2

0xB9CB7Ef204D4C230d175e217C8Feb5b1576757a8

VRF KeyHash Info

Contracts Description
Contract Address

KeyHash 1 (Max Gas: 5 GWEI)

0x45ed5ae4effe3b637692a8a88bbfaaae56dcd21ea76faeb8648e51d56ff74c4c

KeyHash 2 (Max Gas: 10 GWEI)

0x9a8f6e7f086cad087297b571c800e2c71a6d02e727c1d20939607ebd72f9fd69

Last updated