this is RandomNumberConsumer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";

contract RandomNumberConsumer is VRFConsumerBase {
    event RequestFulfilled(bytes32 requestId, uint256 randomness);

    bytes32 internal keyHash;
    uint256 internal fee;
    uint256 public randomResult;

            0x7a1BaC17Ccc5b313516C5E16fb24f7659aA5ebed, // VRF Coordinator
            0x326C977E6efc84E512bB9C30f76E30c160eD06FB // LINK Token
        keyHash = 0x4b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f;
        fee = 0.1 * 10 ** 18; // 0.1 LINK (Varies by network)

     * Requests randomness
    function getRandomNumber() public returns (bytes32 requestId) {
            LINK.balanceOf(address(this)) >= fee,
            "Not enough LINK - fill contract with faucet"
        return requestRandomness(keyHash, fee);

     * Callback function used by VRF Coordinator
    function fulfillRandomness(
        bytes32 requestId,
        uint256 randomness
    ) internal override {
        randomResult = randomness;
        emit RequestFulfilled(requestId, randomness);


I deployed and verified my contract in mumbai testnet. And I send link token to deployed contract. But error occurs When I call getRandomNumber. "We were not able to estimate gas. There might be an error in the contract and this transaction may fail" How can I fix it?

1 Answer 1


Chainlink VRF has been updated, your contract interacts with the V2 contract the way you're meant to interact with V1. Either switch the contract address to v1 (0x8C7382F9D8f56b33781fE506E897a4F1e2d17255 on mumbai) or update your contract so it's compatible with v2 (docs for reference)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.