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;
constructor()
VRFConsumerBase(
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) {
require(
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?