I seem to be doing everything exactly as stated in the docs and example code I am following.

When I deploy this to polygon mumbai though and call "generateRandomNumber" it just reverts with no error message whatsoever...

Note: calling it on polygon mumbai network, and I have already sent some link token to the smart contract

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/v1.11.0/contracts/src/v0.8/VRFConsumerBase.sol";

contract RandomNumberGenerator is VRFConsumerBase {

    uint256 public randomNumber;

    bytes32 public requestId;
    bytes32 public fullfilledId;

    address vrfCoordinator = 0x7a1BaC17Ccc5b313516C5E16fb24f7659aA5ebed;
    address linkAddress = 0x326C977E6efc84E512bB9C30f76E30c160eD06FB;

    constructor() VRFConsumerBase(vrfCoordinator, linkAddress) { }

    function generateRandomNumber() public {
        bytes32 _keyHash = 0x4b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f;
        uint256 _fee = 0.0005 * 10e18;

        requestId = requestRandomness(_keyHash, _fee);

    function fulfillRandomness(bytes32 _requestId, uint256 randomness) internal override {
        // require(requestId == _requestId, "Request Ids don't match!");

        fullfilledId = _requestId;

        randomNumber = randomness;

3 Answers 3


It is because you used the legacy version of the VRF Consumer smart contract, which is deprecated. You should migrate to VRFv2, you can grab the example consumer contract from the Chainlink official docs.

Fyi, the calculation with 0.0005 is not a problem. The following contract works as expected:

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

contract Test {
    function getFee() public pure returns(uint256) {
        uint256 _fee = 0.0005 * 10e18;
        return _fee;

Solidity doesn't accept floar numbers like 0.0005 you clould change it for somethic like:

  uint256 _fee = 10e18 * 5 / 10e4;

Hope it helps!


I don't think you use the correct address for VRF try this: https://blog.chain.link/how-to-get-a-random-number-on-polygon/

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.