# VRF Billing
Source: https://docs.chain.link/vrf/v2/estimating-costs

> For the complete documentation index, see [llms.txt](/llms.txt).

This guide explains how to estimate VRF V2 costs for both the subscription and direct funding methods.

> **TIP: VRF V2.5 billing information**
>
> VRF V2.5 adds the option to pay for VRF requests with native tokens as well as LINK. Learn more about [VRF V2.5
> billing](/vrf/v2-5/billing).

## VRF v2 cost calculator

## Understanding transaction costs

### Estimate gas costs

### Add LINK premium

### Ethereum example

### Arbitrum

The total transaction costs for using Arbitrum involve both L2 gas costs and L1 costs. Arbitrum transactions are [posted in batches to L1 Ethereum](https://developer.arbitrum.io/inside-arbitrum-nitro/#how-the-sequencer-publishes-the-sequence), which incurs an L1 cost. For an individual transaction, the total cost includes part of the L1 cost incurred to post the batch that included the transaction.

To learn how to estimate gas costs for Arbitrum, refer to the [Arbitrum gas estimation tutorial](https://developer.arbitrum.io/devs-how-tos/how-to-estimate-gas) and the full [Arbitrum gas estimation script](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/gas-estimation) using their SDK. There is also a [**version of Arbitrum's gas estimation script extended to include VRF calculations**](#arbitrum-and-vrf-gas-estimation-code).

#### Estimating Arbitrum gas costs with VRF

#### Arbitrum and VRF gas estimation code

This sample extends the [original Arbitrum gas estimation script](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/gas-estimation) to estimate gas costs for VRF subscription and direct funding requests on Arbitrum.

The following snippet shows only the VRF variables and calculations that were added to the Arbitrum gas estimation script. To learn more about how Arbitrum gas is calculated, refer to the [Arbitrum gas estimation tutorial](https://developer.arbitrum.io/devs-how-tos/how-to-estimate-gas). To run this code, use the [**full Arbitrum gas estimation script that includes VRF calculations**](https://github.com/smartcontractkit/smart-contract-examples/tree/main/vrf-arbitrum-gas-estimation).

```typescript
// VRF variables and calculations
// ---------------------------------
// Full script: https://github.com/smartcontractkit/smart-contract-examples/tree/main/vrf-arbitrum-gas-estimation
// ---------------------------------
// Estimated upper bound of verification gas for VRF subscription.
// To see an estimate with an average amount of verification gas,
// adjust this to 115000.
const maxVerificationGas = 200000

// The L1 Calldata size includes:
// Arbitrum's static 140 bytes for transaction metadata
// VRF V2's static 580 bytes, the size of a fulfillment's calldata abi-encoded in bytes
// (from s_fulfillmentTxSizeBytes in VRFV2Wrapper.sol)
const VRFCallDataSizeBytes = 140 + 580

// For direct funding only. Coordinator gas is verification gas
const wrapperGasOverhead = 40000
const coordinatorGasOverhead = 90000

// VRF user settings
const callbackGasLimit = 175000

// Estimate VRF L1 buffer
const VRFL1CostEstimate = L1P.mul(VRFCallDataSizeBytes)
const VRFL1Buffer = VRFL1CostEstimate.div(P)

// VRF Subscription gas estimate
// L2 gas price (P) * (maxVerificationGas + callbackGasLimit + VRFL1Buffer)
const VRFL2SubscriptionGasSubtotal = BigNumber.from(maxVerificationGas + callbackGasLimit)
const VRFSubscriptionGasTotal = VRFL2SubscriptionGasSubtotal.add(VRFL1Buffer)
const VRFSubscriptionGasEstimate = P.mul(VRFSubscriptionGasTotal)

// VRF Direct funding gas estimate
// L2 gas price (P) * (coordinatorGasOverhead + callbackGasLimit + wrapperGasOverhead + VRFL1Buffer)
const VRFL2DirectFundingGasSubtotal = BigNumber.from(coordinatorGasOverhead + wrapperGasOverhead + callbackGasLimit)
const VRFDirectFundingGasTotal = VRFL2DirectFundingGasSubtotal.add(VRFL1Buffer)
const VRFDirectFundingGasEstimate = P.mul(VRFDirectFundingGasTotal)
```