import Vrf2_5Common from "@features/vrf/v2-5/Vrf2_5Common.astro"
import { Aside } from "@components"

<Vrf2_5Common callout="security" />

**Chainlink VRF (Verifiable Random Function)** is a provably fair and verifiable random number generator (RNG) that enables smart contracts to access random values without compromising security or usability. For each request, Chainlink VRF generates one or more random values and cryptographic proof of how those values were determined. The proof is published and verified onchain before any consuming applications can use it. This process helps ensure that results cannot be tampered with or manipulated by any single entity including oracle operators, smart contract developers, users, miners, or block builders\*.

\*In the unlikely event that an adversary compromises VRF's randomness-generating secret key and obtains the ability to construct blocks on the target chain, they could strongly bias the result.

<Aside type="note" title="Migrate to V2.5">
  Follow the [migration guide](/vrf/v2-5/migration-from-v2) to learn how VRF has changed in V2.5 and to get example
  code.
</Aside>

Use Chainlink VRF to build reliable smart contracts for any applications that rely on unpredictable outcomes:

- Building blockchain games and NFTs.
- Random assignment of duties and resources. For example, randomly assigning judges to cases.
- Choosing a representative sample for consensus mechanisms.

VRF v2.5 includes [all the original benefits of v2](https://blog.chain.link/vrf-v2-mainnet-launch/) and the following additional benefits:

- Easier upgrades to future versions.
- The option to pay for requests in either LINK or native tokens.

Learn how to [migrate to VRF v2.5](/vrf/v2-5/migration-from-v2).

For help with your specific use case, [contact us](https://chain.link/contact) to connect with one of our Solutions Architects. You can also ask questions about Chainlink VRF on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=chainlink).

## Two methods to request randomness

Similarly to VRF v2, VRF v2.5 will offer two methods for requesting randomness:

- [Subscription](/vrf/v2-5/overview/subscription): Create a subscription account and fund its balance with either native tokens or LINK. You can then connect multiple consuming contracts to the subscription account. When the consuming contracts request randomness, the transaction costs are calculated after the randomness requests are fulfilled and the subscription balance is deducted accordingly. This method allows you to fund requests for multiple consumer contracts from a single subscription.
- [Direct funding](/vrf/v2-5/overview/direct-funding): Consuming contracts directly pay with either native tokens or LINK when they request random values. You must directly fund your consumer contracts and ensure that there are enough funds to pay for randomness requests.

## Choosing the correct method

Depending on your use case, one method might be more suitable than another. Consider the following characteristics when you choose a method:

{/* prettier-ignore */}
| [Subscription method](/vrf/v2-5/overview/subscription) | [Direct funding method](/vrf/v2-5/overview/direct-funding) |
| ------------------------------------------------- | --------------------------------------------------|
| Currently available on VRF v2.5 for all supported networks. | Currently available on VRF v2.5 for all supported networks. |
| Suitable for regular requests | Suitable for infrequent one-off requests |
| Supports multiple VRF consuming contracts connected to one subscription account | Each VRF consuming contract directly pays for its requests |
| VRF costs are calculated after requests are fulfilled and then deducted from the subscription balance. Learn [how VRF costs are calculated for the subscription method](/vrf/v2-5/overview/subscription). | VRF costs are estimated and charged at request time, which may make it easier to transfer the cost of VRF to the end user. Learn [how VRF costs are calculated for the direct funding method](/vrf/v2-5/overview/direct-funding). |
| Reduced gas overhead and more control over the maximum gas price for requests | Higher gas overhead than the subscription method |
| More random values returned per single request. See the maximum random values per request for the [V2.5 subscription supported networks](/vrf/v2-5/supported-networks). | Fewer random values returned per single request than the subscription method, due to higher overhead. See the maximum random values per request and gas overhead for the [V2 direct funding supported networks](/vrf/v2-5/supported-networks). |
| You don't have to estimate costs precisely for each request. Ensure that the subscription account has enough funds. | You must estimate transaction costs carefully for each request to ensure the consuming contract has enough funds to pay for the request. |
| Requires a subscription account | No subscription account required |
| VRF costs are billed to your subscription account | No refunds for overpayment after requests are completed |

## Supported networks

The contract addresses and gas price limits are different depending on which method you use to get randomness. You can find the configuration, addresses, and limits for each method on the [Supported networks](/vrf/v2-5/supported-networks) page.

To learn when VRF v2.5 becomes available on more networks, follow us on [Twitter](https://twitter.com/chainlink) or sign up for our [mailing list](/resources/developer-communications?parent=vrf).