What is Chainlink VRF?

Chainlink logo

When dealing with computers, randomness is an important but difficult issue to handle due to a computers deterministic nature. This is true even more so when speaking of blockchain technology because not only is the computer deterministic, but it is also transparent.

As a result, trusted random numbers cannot be generated natively in Solidity (the language used to code all smart contracts for EVM compatible blockchains). If each node came up with their own random number they would not be sure whose random number to use when they went to reach consensus. We could solve this by looking outside of the blockchain to get a random number but then this introduces a central point of failure and forces users/developers to have trust in this centralized source of randomness.

The solution to this problem is Chainlink VRF which can help us produce a provably random number and have that randomness credibly verified on the blockchain.

Chainlink VRF (Verifiable Random Function) is used by blockchain developers as a tamper proof random number generator to build reliable smart contracts by producing a provably fair and verifiable source of randomness.

This might seem trivial but it is especially important for tasks that rely on unpredictable outcomes such as NFT’s, blockchain games, or choosing a representative sample for consensus mechanisms. It helps accomplish this task by enabling smart contracts to access randomness without compromising on security or usability.

Chainlink VRF follows the Request & Receive Data cycle which works like this: in one transaction we make a request to an oracle and then in a second transaction the oracle sends a response with the data back. To make this request our smart contract must be funded with enough LINK to pay the specified fee.

The LINK token follows an ERC-677 token standard which is backwards compatible with the popular ERC-20 token but also contains some improvements that make working with oracles cheaper, easier, and more efficient. This works similarly to how requesting storage or computation on the Ethereum network requires a gas fee paid in ether. However, with Chainlink the cost per request depends on the oracle themselves and each individual node operator can set the price at whatever they see fit.

The first step in using Chainlink VRF to generate a random number in Solidity is to determine a seed (a number used to initialize a pseudo-random number generator). It is very important that you pick a seed that is difficult and near impossible to predict or influence.

Your seed is sent in a request to a Chainlink oracle. Every time there is a request for randomness, Chainlink VRF generates a pseudo-random number along with a cryptographic proof of how that number was determined. This proof is published and verified on the blockchain before it can ever be used by any potential applications.

These cryptographic proofs are generated using public-key cryptography which is widely accepted and used throughout the blockchain industry. The fact that the result can be verified for legitimacy is vitally important because this helps ensure that the process cannot be tampered with or manipulated by anyone including miners, users, developers or oracle operators that might benefit from doing so.

Another important thing to note on this process is that network congestion can occur on many blockchains from time to time and result in transactions taking longer to be included in a block. Despite this, VRF nodes will still continue responding to randomness requests but the fulfillment response times could increase in proportion to the level of network congestion. This may be important to account for in specific use cases.

So is there a potential downside?

According to the Chainlink documentation, “The fundamental benefit of using Chainlink VRF is its verifiable randomness. Even if a node is compromised, it cannot manipulate and/or supply biased answers because the on-chain cryptographic proof would fail. The worst-case scenario is that the compromised node does not return a response to a request, which will immediately and forever be visible on the blockchain. Users would no longer rely on nodes that stop responding and/or don’t provide randomness with a valid proof. Even in the unlikely scenario that a node is compromised, its resulting randomness cannot be manipulated. Compromised nodes can only withhold a request, giving no response, for which they would be financially penalized using Chainlink’s upcoming staking capabilities and removed from future queries that would have paid fees for their randomness, creating a substantial immediate and long-term economic loss for low quality and/or misbehaving node operators.”

So basically, Chainlink VRF cannot manipulate an application that uses it properly and it can only go offline or withhold a single result before being removed as a source of any future randomness. This creates superior security for smart contract developers and their users.

Smart contract developers should always have security at the top of their priority list in order to defend themselves and their users from adversaries who would potentially seek to steal funds from their smart contracts. When writing smart contracts that rely on randomness we would ideally want a provably fair and equally uncertain process while minimizing adversarial risk. Chainlink VRF fulfills this need by proving randomness via on-chain cryptographic proofs showing that the produced randomness is indeed unpredictable.

By using Chainlink VRF, developers can build reliable smart contracts for many applications that require unpredictable outcomes and in the process accomplish a wide variety of randomness dependent tasks such as make games more trustworthy or choosing a representative sample of observers eligible to vote on a proposal the contract needs to establish consensus.

With Chainlink VRF already being utilized by many major projects such as OlympusDAOBored Ape Yacht ClubPolygon, and Illuvium it seems that this is only the beginning of the many future use cases for this important feature that could continue to help fuel the growth of the Chainlink ecosystem as a whole.

Previous
Previous

BTC Consolidates Into Weekend

Next
Next

Bitcoin Continues to Test Support