Supra

Chainlink VRF: Complete Explanation And Alternatives

September 20, 2023 - 12 min read

Chainlink’s VRF Service Is Currently Dominant, But Cross-Chain Competition Is Increasing 

A VRF, or verifiable random function, is a cryptographic function that allows an entity to create a random number and prove to another entity or entities that the number was generated using a secret key. Within the scope of blockchain smart contracts, VRFs are needed for various purposes, including blockchain-based lotteries, GameFi NFTs with randomized traits, and node or validator randomization. Chainlink VRF is currently the industry-leading VRF service for blockchain, crypto, gaming, and DeFi protocols. Users can subscribe to Chainlink VRF through a subscription account or pay directly for a single contract. 

Despite Chainlink’s dominance in the VRF space, Chainlink’s verifiable random function service is far from the only VRF out there, and a variety of newer options have popped up over the last two years. However, it’s unclear when and if these other options, many of which are chain-specific, will become more popular than Chainlink’s cross-chain VRF. 

In this article, we’ll review how Chainlink VRF and other VRFs operate, as well as discuss newer competitors to Chainlink’s VRF service, including Binance VRF, Harmony VRF, Algorand VRF, Supra VRF, Sui Move VRF, and Solana’s Switchboard VRF. 

How Does Chainlink VRF Work? 

The Chainlink VRF smart contract verification process. Source: Chainlink. 

Chainlink’s verifiable random function service acts as a verifiable random number generator (RNG), which creates verifiably random outputs that can be used by dApps and other applications that require on-chain randomness. It works by publishing and verifying the randomness proof on-chain before any application can use it. Anyone can verify the proof using the public key corresponding to the secret key. 

Since the proof is published before consumption by smart contracts, it generally cannot be manipulated or tampered with by associated entities, including smart contract developers, miners, or other users. 

How To Use Chainlink VRF 

As previously mentioned, users can pay to use Chainlink VRF by subscription or direct funding. 

Using Chainlink VRF With A Subscription 

To subscribe, a user must create a subscription account and fund its balance with Chainlink’s native LINK tokens. Chainlink calculates the transaction costs after requests are fulfilled, and credits will be accordingly deducted from a user’s subscription balance. One subscription account can be connected to multiple smart contracts. Subscriptions are typically better for those with regular VRF requests, those who want to reduce gas overhead and have more control over gas costs, those who want more random values per request, or those who don’t want to precisely estimate the costs for each request. 

Chainlink’s Subscription Manager allows users to create accounts and prepay for Chainlink VRF v2. This allows users to use a single wallet to fund multiple Chainlink products, not just VRF services.  

Chainlink subscriptions involve: 

  • Subscription Accounts: To use Chainlink VRF, an account must contain sufficient LINK tokens and make them available to fund requests. 
  • Subscription Owner: The Subscription Owner is the wallet address that funds the subscription account. While other wallets can add LINK to the subscription account, only the wallet’s owner can spend LINK tokens for VRF requests or withdraw LINK tokens altogether. 
  • Subscription Balance: This is defined as the amount of LINK currently maintained in a user’s subscription account. 
  • Consumers: Consumers are defined as contracts that the subscription owner approves to use LINK tokens for VRF requests. 
  • Subscription ID: The Subscription ID represents a unique identifier as a 64-bit unsigned integer. 

Chainlink VRF’s gas cost calculation is determined by factors including:

  • Current Gas Price: This is defined as the current gas price, which varies regularly based on network usage (i.e., supply and demand). 
  • Callback Gas Price: This is defined as the gas cost of the callback request, which provides the random value/random number due to the subscription account’s VRF request. Callback gas prices depend on the number of random values in a request. 
  • Verification Gas: This is the gas cost used to verify the randomness of the number on-chain. 

Additionally, users can pre-set the maximum amount they want to spend on VRF requests via manipulating the following factors: 

  • Gas Lane: This is the maximum gas price a user wants to pay for a single request, which can be specified via keyHash. Prices can spike on Chainlink’s network, and prices increase for users that want their requests filled quickly, so this can be important for users who wish to save on total gas costs. 
  • Callback Gas Limit: The Callback Gas Limit allows a user to denote the maximum gas amount they are willing to spend on a callback request, which can be specified by using the callbackGasLimit value. 

Using Chainlink VRF With Direct Funding 

In contrast, direct funding involves a smart contract directly paying with LINK tokens as they request a VRF. The contract must be funded sufficiently to pay for requests, or they will not be completed. This is generally better for entities with fewer requests that are okay with spending higher amounts of gas. In addition, entities using direct funding need to be ready to measure transaction costs carefully for each request to ensure the consuming smart contract has sufficient funds to pay for it.

Two Ethereum account types can be used for direct funding VRF requests, including smart contracts and Externally Owned Accounts (EOAs). 

  • Smart Contracts: Smart contracts that don’t have a private key and simply execute a series of steps for a dApp can be used to fund VRF requests directly.  
  • EOAs (Externally Owned Accounts): An EOA, or Externally Owned Account, is an account with a private key that can control one or more smart contracts. Only EOAs can initiate transactions. 

On-chain and off-chain components are used in Chainlink VRF, including: 

  • VRF v2 Wrapper: This on-chain component provides an interface for consuming contracts. 
  • VRF v2 Coordinator: This on-chain component is a contract intended to interact with Chainlink VRF. The contract “emits” a request for a random number, verifies the random number, and provides cryptographic proof of how the number was randomly generated. 
  • VRF Service: This off-chain component of Chainlink VRF “listens” for VZRF requests via a subscription to VRF Coordinator logs, using block hashes and nonces to generate random numbers. It then sends a transaction back to the VRF coordinator with the random number and cryptographic proof of how the number was generated. 

The Limitations of Chainlink VRF

While Chainlink VRF is powerful, it does have some limitations. Unlike Chainlink’s core oracle service, which is available on many blockchains, Chainlink VRF is currently only compatible with the Ethereum blockchain, which can be very limiting for developers working on other Layer 1 blockchains like Solana, Avalanche, BNB Smart Chain, Aptos, Sui, and other similar chains. 

In addition, Chainlink VRF may have both foreseen and unforeseen security issues due to the potential centralization of the Chainlink network and collusion by Chainlink node operators. Therefore, while unlikely, in theory, a number generated via Chainlink VRF could be estimated or foreseen if enough node operators collaborated or colluded together. This could allow node operators or associated entities to “game” the system and unfairly win GameFi lotteries or increase the chance that a “randomly” generated NFT has extremely rare traits. 

In addition, Chainlink’s core network is also not immune to outside exploits from non-node operators, and Chainlink exploits have led to significant node operator losses. For example, in 2020, an attacker spammed nine Chainlink nodes to drive up the cost of gas on the network, draining node operators’ hot wallets of 700 ETH (almost $250,000 at the time). While this attack did not impact external blockchain or DeFi protocols using Chainlink’s data feeds, this shows that it is possible that outside hacks or exploits could potentially manipulate different Chainlink services, including their VRF service. 

As previously stated, some of the most popular Chainlink VRF competitors include Binance VRF, Harmony VRF, Algorand VRF, Supra VRF, Sui Move VRF, and Solana’s Switchboard VRF. 

Binance Oracle VRF

Much like Chainlink VRF, Binance Oracle VRF, powered by Binance Cloud, is a VRF service that allows blockchain developers to generate random numbers. It can be used for various smart contract use cases, including GameFi applications. Binance calls Binance Cloud “an infrastructure solution for customers and partners to launch digital asset exchanges leveraging Binance’s industry-leading technology, security, and liquidity.”

While Binance’s global brand gives Binance Oracle VRF a substantial amount of clout, Binance’s products, including its core branded blockchain, BNB Smart Chain, are relatively centralized, and so is Binance Cloud. This means that Binance VRF could potentially be “gamed” or manipulated by people working inside Binance, particularly if there are no strict controls. With little transparency behind how the oracle is managed, this could create potential conflicts of interest and serve as a centralized point of failure for dApps using this service. 

Binance Oracle VRF combines two independent sources to generate seeds. Randomness is created by the off-chain provider, and its private key is created via the block-has and preSeed parameters, intended to ensure unpredictability, as users cannot predict the block hash until it’s generated. 

Harmony VRF

Harmony is an increasingly popular Layer-1 blockchain, and as of mid-to-late 2023, its native token, ONE, had a market cap of over $130 million. Harmony also has a VRF service, which it claims creates an “optimal solution for randomness that is unpredictable, unbiasable, verifiable, and immediately available.”

Furthermore, Harmony says that its VRF was built using its existing cryptographic primitive of BLS signatures, leading to high efficiency. All Harmony smart contracts can access VRF random outputs through precompiled contracts with no extra fees. 

Specifically, a private key “SK” is utilized to create an arbitrary, randomized message output and a proof, which can be verified by any entity that knows the corresponding public key “PK.” 

According to Binance, for each additional block, the block-producing validator computes a VRF based on their private key and “the latest block hash to produce a 32-byte VRF output and 96-byte proof. The VRF output and proof are concatenated as 128-byte data and put in the VRF field of the header of the newly proposed block.”

Alogrand VRF

How VRFs function as a part of Algorand’s core consensus mechanism. Source: Binance Research. 

Algorand’s VRF, unlike some other VRFs, is heavily integrated into Algorand’s consensus model rather than being a separate, standalone service. Specifically, Algorand uses VRFs to secretly select which committees of nodes will provide consensus at any one time, helping Algorand stay decentralized and highly scalable. Algorand’s VRF uses three main algorithms: Keygen, Evaluate, and Verify.

Algorand says,” On a random input, the key generation algorithm produces a verification key VK and a secret key SK pair…. The evaluation algorithm takes as input the secret key SK, a message X, and produces a pseudorandom output string Y and a proof ⍴… The verification algorithm takes as input the verification key VK, the message X, the output Y and the proof ⍴. It outputs 1 if and only verifies that Y is the output produced by the evaluation algorithm on inputs SK and X.”

Supra VRF

While a newer entrant to the VRF space, Supra VRF is perhaps the most powerful, most decentralized VRF on the market today. Unlike more centralized VRFs, Supra VRF utilizes a privacy-preserving algorithm that distributes power over a series of nodes to prevent node collusion and centralized points of failure. This allows smart contract developers to create truly tamper proof randomness and to leverage random outcomes for a wide range of applications.

Supra VRF is also designed for high scalability, as it uses transaction bathing to reduce gas costs and improve speed. 

In addition to its scalability, unlike many other entrants to the space, Supra’s VRF service is natively cross-chain. It can be easily deployed to 25+ blockchains, including Ethereum, all major Layer 2s, including Optimism, Arbitrum, and Polygon, and many of the most popular Layer 1 chains, including Aptos, Avalanche, and Sui. Finally, Supra VRF is designed for an extremely low-latency response and can generate truly random numbers almost instantly. This is ideal for things like GameFi applications, where players opening a loot box want to see a prize instantly– instead of waiting several minutes for the prize to load. 

Sui Move VRF

Like other VRFs, Sui Move VRF allows users to access random values and prove to others that the requested random values are truly random via the use of a secret key. Sui Move VRF uses a well-known and highly effective form of cryptography called Elliptic Curve Multiplication, in which a large, random number is generated such that it is nearly impossible to determine the factors. These factors are incorporated into the secret key, making this type of cryptography extremely secure and hence, a popular way to generate private keys for many crypto wallets. Sui’s Elliptic Curve VRF (ECVRF) specifically uses the popular SHA-512 hash function.

Using the open-source Sui Move framework, developers can generate their own VRFs using Sui Move’s fastcrypto library to output a secret key and a public key in hex format. According to Sui Move documentation, “the secret key is a 32-byte string, and the public key is a 32-byte string…. The proof and output can be verified in a smart contract using sui::ecvrf::ecvrf_verify from the Sui Move framework, and it can also be verified using the [Sui’s] CLI tool.” 

Solana Switchboard VRF

Solana Switchboard VRF is currently the most popular verifiable random function service on the Solana blockchain. Deployed in May 2021, Switchboard provides data feeds and verifiable randomness “using a round-robin queue of off-chain oracles fulfilling update requests. The Attestation Program supports functions, secrets, and legacy data feeds using an attestation service to verify that the execution of off-chain code was conducted within a trusted execution environment (TEE).” 

Furthermore: “Switchboard Functions allow you to execute your own code off-chain in a verifiable manner allowing you to build more dynamic programs. This allows you to publish ANY data you want on a cron-based schedule, perform basic maintenance operations, and execute async operations for your users!” 

According to Solana documentation, Switchboard allows users to perform off-chain checks to ensure data has been refreshed regularly and to prevent oracle extractable value attacks, all while maintaining a high level of security. While this can be very gas-heavy and computationally intensive (often requiring nearly 50 transactions), users can utilize Randomness Callback Function to generate randomness in just one transaction.

In Conclusion: VRFs Are Essential To Decentralized Applications, But Chainlink Is Far From The Only Option

Chainlink VRF is currently the most popular VRF service on the market today and is used by a wide array of crypto, DeFi, and GameFi projects and protocols. However, despite its popularity, Chainlink VRF isn’t without its limitations. For one, Chainlink’s core consensus has raised certain centralization concerns, and these potential issues could flow downstream to its VRF service. In addition, while Chainlink operates a Cross-Chain Interoperability Protocol (CCIP) for its main oracle service and VRF, it’s unclear whether Chainlink VRF can easily and quickly be deployed on chains other than Ethereum. Finally, Chainlink VRF, while fast, sometimes causes delays and displays longer-than-average latency, which could cause issues for DeFi and GameFi applications using their VRF protocol. 

Fortunately, there are other VRF options, though most of them, like Binance VRF, Solana Switchboard VRF, and Algorand VRF, are generally limited to a single blockchain and don’t appear to have much potential for cross-chain interoperability. However, newer VRF services, such as Supra VRF, are highly randomized and natively cross-chain, giving them a significant edge over Chainlink. Due to this, we could easily see Supra and other newer, cross-chain VRF competitors begin to take market share away from Chainlink and create true competition in the VRF space.  

References: 

  1. Introduction to Chainlink VRF. Chainlink. 
  2. Chainlink VRF: Subscription Method. Chainlink. 
  3. Chainlink VRF: Direct Funding Method. Chainlink. 
  4. Southurst, J. (Sep. 2020) Chainlink exploits lead to ETH losses—again. Coingeek. 
  5. (Jul. 2022) Why Is Binance Cloud Your Best Choice to Create Your Own Crypto Exchange? Binance
  6. Harmony VRF. Harmony
  7. Gorbunov, S. (Oct. 2018) Algorand Releases First Open-Source Code: Verifiable Random Function. Medium: Algorand
  8. Supra VRF. Supra
  9. Verifiable Random Function (VRF). Sui
  10. Switchboard X Solana. Switchboard. 
  11. Cross-chain by Chainlink. Chainlink. 
twitterlinkedinfacebookmail

RECENT POSTS

獲取新聞、見解等信息

註冊Supra通訊,獲取公司新聞、行業見解等信息。當我們退出隱形模式時,您還將第一時間獲知。

隐私使用條款網站資料使用與Cookies漏洞揭露生物特徵資訊隱私政策

©2024 Supra | Entropy基金會(瑞士註冊號:CHE.383.364.961)。保留所有權利。