Search code examples
blockchainethereumsoliditychainlink

Chainlink vrf v2 request gas fee amount


I'm trying to understand exactly how much it costs(in LINK) to fund the gas fee for a chainlink VRF V2 random value request on Ethereum mainnet.

There's a formula here about it but i'm not sure im getting it right.

Any help would be appreciated.


Solution

  • As per the docs link you listed, the cost for a VRF V2 request is split into two parts:

    1. Gas Cost for the callback transaction the VRF node needs to make (which includes the on-chain verification of the VRF result). This is then multiplied by the current gas price for the network at the time, which also depends on your selected gas lane (The maximum gas price you are willing to pay for a request in Wei). Once a total gas cost is reached, it's converted to LINK using the ETH/LINK price feed. This full fee is to compensate the VRF node for the transaction they need to make back on-chain to fulfill your request.
    2. Premium is applied to each request in LINK that the node operator sets. This is the fee in LINK the VRF node sets for fulfilling each request and is separate from the compensation for gas costs outlined in the previous point.

    Adding those two values together gives you the total cost in LINK for a VRF node to fulfill a VRF request.

    Example:

    Using the following parameters:

    • 500gwei gas lane
    • 100000 Callback gas limit
    • 200000 Max verification gas
    • 0.25 LINK premium

    500 x (200000 + 100000) = 150000000 gwei total gas cost

    150000000 gwei = 0.15 ETH convert to LINK using the LINK/ETH feed (at the time of this answer, the feed currently shows Ξ0.0035616455 ETH per 1 LINK)

    0.15 ETH / 0.0035616455 = 42.115364934550617 total LINK for gas costs

    0.25 LINK + 42.115364934550617 = 42.365364934550617 LINK cost for a request.

    Take note that this is just the maximum amount that could be charged; the gas price of 500 won't necessarily be used; this is just the max that a transaction would be bumped to. Also, the limits for callback and verification won't necessarily all be used either, which would also affect the final amount. The only figure guaranteed to be used in the final calculation is the LINK premium, as the VRF node sets that.