Verifiable Random Numbers (VRN)
LinkWell Nodes can deliver Verifiable Random Numbers (VRNs) to the smart contract of your choice using our cryptographically secure and provably random number generation (RNG) service.
On this page:
Overview
LinkWell Nodes' Verifiable Random Numbers (VRN) service is a cryptographically secure random number generator (RNG) that sends random numbers to your on-chain smart contract.
Unlike traditional random number generators, VRN allows you to independently verify that the numbers provided were generated fairly, using a pre-committed secret seed.
Looking to integrate VRN?
Skip ahead to our implementation guide.
Is LinkWell's VRN the same as Chainlink's VRF?
No. VRN is a different service that provides a similar level of security and verifiability, but added ease of implementation, free testnet usage, and minimal-cost mainnet usage. For more information, visit our feature comparison table.
Features
- Cryptographically Secure: Seeds are generated randomly using a secure cryptographic hashing algorithm.
- Verifiable: All random numbers can be independently verified using the seed.
- Tamper-Proof: Seeds are revealed only after a delay, preventing manipulation.
- Custom Ranges: Specify your desired min and max random number value, saving costly gas otherwise required to normalize the result upon receiving it.
- Multiple Values: Request just one random number, or multiple random numbers at once, saving time and gas otherwise required to make multiple requests.
- Gas Efficient: Computation happens off-chain, minimizing gas costs.
Key concepts
-
Seed Generation:
- Our infrastructure generates a new cryptographically secure random seed every 6 hours (also known as an 'epoch')
- Each seed is hashed and stored securely on our SOC-2 compliant infrastructure
- Seeds only become publicly available once their respective epoch has ended, to prevent manipulation
-
Random Number Request
- Your smart contract's
request()
function requests a random number within the specifiedminVal
andmaxVal
(inclusive) - Our oracle uses the current epoch's secret seed to generate your random number
- Our oracle returns both the random number and the seed's one-way hash to your smart contract
- Your smart contract's
-
Verification
LinkWell Nodes VRN vs. Chainlink Labs VRF
LinkWell Nodes' VRN (Verifiable Random Numbers) service is a comparable alternative to Chainlink Labs' VRF (Verifiable Random Function) service. The following feature comparison table will help you decide which option is right for your business:
Full feature comparison table
Feature | LinkWell Nodes VRN | Chainlink Labs VRF |
---|---|---|
Randomness generation | Yes | Yes |
Configurable range (min/max) | Yes | No |
Verifiability | Yes | Yes |
Ease of integration | Medium | Medium |
Supported networks | 14 | 7 |
Cost | Typically lower | Typically higher |
Pay in LINK | Yes | Yes |
Pay in native gas token | Yes | Yes |
Pay in stablecoins | Yes | No |
Pay in fiat | Yes | No |
Response time (blocks) | 2-3 (chain-dependent) | 2-3 (chain-dependent) |
Infrastructure | Private, SOC-2 compliant infrastructure | Decentralized oracle network (DON) |
Free monitoring | Yes (mainnet requests) | No |
Free dedicated support | Yes (mainnet requests) | No |
Implementation guide
Step 1: Deploy your VRN consumer contract
Deploy your own VRN consumer contract to start requesting verifiable random numbers:
-
Visit our mainnet or testnet job documentation pages and navigate to your desired blockchain network.
-
Under "Select the data type that you need", select the data type (ie,
uint256[]
). -
Click "Verifiable random numbers (VRN / RNG)", and scroll down to find the appropriate VRN consumer contract.
Example:
Testnets
->Base Sepolia
->uint256[]
->Verifiable random numbers (VRN / RNG)
- Deploy the consumer contract by pasting it into the smart contract IDE of your choice (ie, Remix).
Step 2: Request a random number
Call the request()
function within your deployed contract, with your desired range specified.
The oracle will respond by calling your contract's fulfill()
function with:
- A request ID (
requestId
) - Random number(s) within your specified range (
_randomNumber
or_randomNumbers
) - The one-way hash of the secret seed used to generate your number(s) (
hash
)
Step 3: Verify the random number(s)
You have two options for verifying your random number(s):
You must wait for the respective seed's epoch to end (every 6 hours) before you can verify your random number(s). Epochs end at the following times each day:
- 00:00:00 UTC
- 06:00:00 UTC
- 12:00:00 UTC
- 18:00:00 UTC
Option 1 (off-chain): Using our website
-
Call the
getHash(requestId)
function, passing in the requestId in question -
Visit our seed verification page, entering your chain ID and hash as URL parameters:
https://linkwellnodes.io/VRN-Seed.html?chain=ENTER_CHAIN_ID_HERE&hash=ENTER_HASH_HERE
chain
: The chain ID for your respective blockchain network can be found at chainlist.orghash
: The hash obtained from thegetHash(requestId)
call within your contract
-
If the seed is available, it will be shown on the page
-
Call
verifyResult(requestId, seed)
with the requestId and the retrieved seed- A return value of
true
confirms that the randomness was verified on-chain
- A return value of
Option 2 (on-chain): Using an oracle request
-
Ensure your contract has sufficient LINK token balance
-
Call
requestSeedFromOracle(requestId)
with your requestId- This will send LINK to our oracle as payment for this transaction
- The required amount of LINK has been pre-specified within this function, and cannot be changed
-
Wait several blocks for our oracle to call
fulfillSeedFromOracle()
- If the seed is available, this will write the seed to your contract's storage
-
Call
verifyResult(requestId)
- A return value of
true
confirms that the randomness was verified on-chain
- A return value of
The logic used for verifying a given random number is as follows:
randomNumber = uint256(keccak256(abi.encodePacked(
seed, // Secret seed for the related epoch
address(this), // Your contract address (prevents cross-contract replay attacks)
requestId, // Unique request ID (prevents replay attacks within your contract)
index // The 0-indexed index of the requested number (0 for requests for a single number)
))) % (maxVal - minVal + 1) + minVal; // The requested lower and upper bounds of the random number(s) (inclusive)
Security
Our VRN service employs multiple security measures:
- Seeds are generated using cryptographically-secure hashing algorithms
- Seeds are encrypted and stored on our secure, SOC-2 compliant infrastructure until their designated reveal time
- Seeds are rotated every 6 hours to prevent manipulation
- All random number generation follows a deterministic and verifiable process
- All operations are verifiable on-chain
Need more help?
Join our Discord server for immediate assistance!