0

I have a simple request and fulfill randomness using chainlink VRF, and it works fine when calling with 0 ether, but if I send a non-zero amount I get a 'gas estimation failed' error.

To be clear, I call requestRandomness(), and then fulfillRandomness is a callback that is called shortly after.

function requestRandomness() public payable {
    require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - contract will be funded soon");
    requestRandomness(keyHash, fee, 0);
}

function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
    randomResult = randomness;
}
3
  • Is there any LINK in the contract when you get the error? You're checking the balance of LINK before doing a request for randomness, and then reverting if there isn't enough, so it sounds like it's this check that's failing. Jun 21 at 0:50
  • There's enough LINK. Like I said, I can call it just fine without sending eth. But if I do send any eth it fails. I found an alternate way to do what I'm trying, but now I'm facing new issues regarding the fulfillRandomness not estimating gas properly... Jun 21 at 5:55
  • ok. with your original issue, does it still fail if you remove the require line in requestRnadomness()? Jun 21 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.