APRO
APRO VRF
APRO VRF
  • VRF
    • APRO VRF
    • Integration Guide
    • On-Chain Costs
  • Attachment
    • Terms of Use
    • Privacy Policy
    • Node operator
Powered by GitBook
On this page
  • 1. Deploy Your Own VRFConsumerV2 Contract
  • 2. Create a Subscription
  • 3. Add a Consumer
  • 4. Fund Your Subscription
  • 5. Request Randomness
  • 6. VRF Information
  1. VRF

Integration Guide

Market Integrity and Application code Risks

PreviousAPRO VRFNextOn-Chain Costs

Last updated 2 months ago

1. Deploy Your Own VRFConsumerV2 Contract

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

  • VRF Coordinator Contract Address: 0xB9CB7Ef204D4C230d175e217C8Feb5b1576757a8

  • Valueless Token Contract Address: 0xF424cAA15eF7F8524bF55bD838935A25cDf1caae

Steps to Deploy

  • Download the contract code from GitHub: 🔗

  • 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 pre-prepared parameters 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. Connect your wallet (top-right corner) and click "Create Subscription".

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

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

  4. 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

solidity function requestRandomness(
    bytes32 keyHash,
    uint64 subId,
    uint16 minReqConfs,
    uint32 callbackGasLimit,
    uint32 numWords
)

Example Input

solidity [
    0x45ed5ae4effe3b637692a8a88bbfaaae56dcd21ea76faeb8648e51d56ff74c4c,
    2,    // Subscription ID
    3,    // Minimum request confirmations
    150000,  // Callback gas limit
    1     // Number of random words
]

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

  • Valueless Token: 0x48Ee5E7E27A5058eBf74c8Bb6A2DD1E6176A84a1

  • BlockHashStore: 0xd3fBd0Cdb7774617fCCa347804Ea48277d586c6A

  • VRF Coordinator V2: 0x8571C322bf9FC9dDD40635300cC534693fef4067

VRF KeyHash Info

  • KeyHash 1 (Max Gas: 0.1 GWEI) 0xe568bd3aa35ca9857f68102223a2313ead8ad257b322306a2649f2dff5fc3235

  • KeyHash 2 (Max Gas: 0.2 GWEI) 0x86af5b5dd69ca4845538ca99ad0087c917fed2475793b4c2c9237556e719c2ca

  • KeyHash 3 (Max Gas: 0.5 GWEI) 0xbdacf5b71bc9b737f8ffcf7612bea13114b1923c2fe6aa5ca0a7deb9a318f22c


6.2 BitLayer Testnet

Contracts

  • Valueless Token: 0xF424cAA15eF7F8524bF55bD838935A25cDf1caae

  • BlockHashStore: 0x70df6E187188e10A6552445Be86C73ce2168a452

  • VRF Coordinator V2: 0xB9CB7Ef204D4C230d175e217C8Feb5b1576757a8

VRF KeyHash Info

  • KeyHash 1 (Max Gas: 0.2 GWEI) 0x797e63f62c966d5a1a2e33228485e3963393c84c0d214300dddcd8b0fec4351800

  • KeyHash 2 (Max Gas: 0.5 GWEI) 0xe0a345818c80cc3536672b175a215341ac8c32c7a9a31b3c3852f57c01b7f13e00

Open the VRF Subscription Manager: 🔗

Subscription Manager
APRO VRF Portal
APRO VRF Contracts