0

I require a random parameter on the BSC test network, which costs about 0.1 ~ 0.15 link tokens each time.

But when I transferred to the BSC mainnet, the cost soared to 113 link tokens. This caught me a bit off guard, where I think the code is different: testnet use: 50 gwei Key Hash 0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314 mainnet use: 1000 gwei Key Hash 0x17cd473250a9a479dc7f234c64332ed4bc8af9e8ded7556aa6e66d83da49f470 Is there a way to tell me where the possible problem is? I already have a little loss because of this question, thanks for answering.

Why is the price difference between the test network and the main network is so large, and where is the problem?

starball
  • 20,030
  • 7
  • 43
  • 238

2 Answers2

0

The 113 LINK cost in the VRF App is the theoretical estimated maximum cost, and the actual cost may be much lower than the estimated cost. I guess your request is pending now for insufficient balance and it is not deducted from your balance.

The formula for Chainlink VRF cost is here. The final cost of VRF request is related to the callback gaslimit, premium fee, verification cost, and most importantly, gaslane(keyhash in your VRF request).

The gaslane you are using is 50gwei in BNBChain testnet, while you selected 1000gwei gaslane in the mainnet. According to the formula above, the estimated gas in mainnet would be at least 200 times more than testnet.

Please try to set a proper callbackgas limit in your VRFConsumer contract and send the request again.

Frank Kong
  • 1,010
  • 1
  • 20
  • 32
  • My contract has been hard-coded and cannot be modified. I am trying to create a new contract, but the test network is 50 gwei, and the main network is 200 gwei. Will it charge about 0.5 link? – Prize World Pixel Apr 03 '23 at 16:33
  • Because I didn't have so many links before, he wouldn't start it, and I didn't dare to put so many links in. If it is really 113, I will really lose everything. – Prize World Pixel Apr 03 '23 at 16:34
  • Hi @PrizeWorldPixel , My suggestion is to redeploy your contract in bnb mainnet and: 1. change the gaslane to 200gwei. Please note 200gwei does not mean the gas price would be definitely 200gwei, it means the max gas price allowed is 200gwei. 2. set a proper callback gaslimit. Test how many gas is used in the testnet and set this value in your contract. 3. Add more funds to your new subscription. Maybe 10-15 LINK. – Frank Kong Apr 04 '23 at 02:11
  • I have seen it, so if I use 200 gwei, the GAS on BSC NET will still be 10-15 Link. I think this may not be able to support what I want to do. Is there a way to not exceed 1 link? ? – Prize World Pixel Apr 04 '23 at 05:39
0

Consider the following calculation for the given formula:

(((Gas lane maximum * (Max verification gas + Callback gas limit)) / (1,000,000,000 Gwei/ETH)) / (ETH/LINK price)) + LINK premium = Minimum LINK

For BSC Mainnet

  • Gas Lane Maximum is 200gwei
  • Max verification gas is always 200,000
  • Callback gas limit is 100000
  • LINK Premium is 0.005
  • ETH/LINK Price is 0.0040368572 (at the time of writing this)

The theoretical estimated maximum cost is 14.89 LINK. However, practically, the cost will be lower due to the current BSC Mainnet GWEI value of 5 (Current) Thus, the minimum LINK required is approximately 0.37 LINK.

NOTE: It is important to note that the above values are only estimations, and actual fees may vary depending on factors such as the Gas Lane, callbackGasLimit, and network congestion.