# Chainlink VRFs

Random numbers cannot be generated on chain because the computers are deterministic and also transparent due to which the randomness info is available to all the miners and the users.

Hence we need some mechanism through which we can generate randomness off the chain and then use this generated random number inside the solidity. We can make use of Chainlink oracles for that. The name of this oracle is Chainlink VRFs.

## What are oracles?

A blockchain oracle passes the data from an outside source to the smart contract.

## Intro to chainlink VRFs.

**Chainlink VRF (Verifiable Random Function)** is a verifiable random number generator that enables smart contracts to access random values without compromising security.

Chainlink VRF generates one or more random values and cryptographic proof of how those values were determined. The proof is published and verified on-chain before any consuming applications can use it. This process ensures that results cannot tamper.

## Methods to generate random numbers:

The chainlink provides us with two methods:

1)The subscription method in which we have a subscription account with some pre-fund balance and all the smart contracts can connect with this account and generate random numbers and the gas fees for generating the random numbers will be deducted from the account.

2)Direct funding method: Here the calling smart contract has to have sufficient LINK tokens balance and the fees for generating the random numbers is deducted from the smart contract itself.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1671479295434/-RPDnIjbh.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1671479773606/27pzj6e8K.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1671479823362/ZE7UA4Lli.png align="center")
