2

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.

1 Answers1

5

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.

Erçin Dedeoğlu
  • 4,950
  • 4
  • 49
  • 69
  • Thanks, but the numbers I'm getting don't seem sensible to me could u do the math for 500gwei gas lane and 100000 Callback gas limit & 200000 Max verification gas & 0.25 LINK premium (thanks in advance I just wanna double check) – Amirhossein Ghk May 17 '22 at 08:59
  • added an example, let me know if it doesn't make sense – Harry Papacharissiou May 18 '22 at 02:27
  • thanks , I got the gist of it. PS are you sure about that 0.15 ETH = 0.15LINK part? – Amirhossein Ghk May 19 '22 at 12:12
  • oops sorry, I forgot to convert the ETH/LINK properly using the price feed! Updated the answer again. This time I'm confident its correct – Harry Papacharissiou May 20 '22 at 01:30
  • Thanks so much, wow that's a lot! – Amirhossein Ghk May 20 '22 at 09:50
  • Remember this is just the upper limit, and the 500gwei lane isn't the cheapest lane either. If you take a look at some of the recent VRF calls on Ethereum mainnet lately, you'll see many transactions are only using around 12-20gwei gas limit, and have total fee in ETH of 0.01 ($3), so the total fee in LINK including the 0.25 premium is probably around the 1 LINK mark https://etherscan.io/address/0x271682DEB8C4E0901D1a1550aD2e64D568E69909 – Harry Papacharissiou May 23 '22 at 02:11
  • yes, but if I want to charge the users beforehand I'm not sure it's worth it because I won't know how much to charge them exactly. – Amirhossein Ghk May 23 '22 at 17:35
  • how would this answer be different if we're considering running vrf on MATIC? Also noting that there's no MATIC / LINK price oracle, would I convert to another denom to figure this out? – ke4mtg Feb 25 '23 at 17:45