Search code examples
soliditychainlink

Chainlink VRF callback gas limit set too low


I'm writing an integration test of my NFT practice project using Chainlink VRF v2 subscription method, but keep getting callback gas limit set too low error

My contract is deployed on sepolia testnet with following settings

  • gas lane: 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c
  • gas limit: 500000
  • vrfcoordinator address: 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625

and the account I use for testing also have enough sepoliaETH

You can find the full implementation of my practice project at https://github.com/ambersun1234/nft and the deployed contract

The subscription of Chainlink VRF that I created currently have 18 Link
The contract will spend 0.2 Link per call

The file for integration test is

Step to reproduce

$ git clone https://github.com/ambersun1234/nft
$ cd nft
$ yarn install
$ yarn hardhat test --network sepolia

I've checked all of the settings correct or not(gas lane, subscription id ... etc.)
and even change the gas limit up to 2500000 but all in vain

To check if Chainlink works on other network, I also checked goerli testnet of my another project and it works


Solution

  • Ok so the issue is simple
    make sure you put _safeMint before _setTokenURI
    otherwise you'll encounter with this weird issue