Search code examples
soliditychainlink

Chainlink VRF : Error encoding arguments: Error: invalid BigNumber string


I'm trying to get a random number with Chainlink VRF, So Hi have follow this demo step by step : https://www.youtube.com/watch?v=JqZWariqh5s

here is what i've copied on Remix :

pragma solidity 0.6.6;

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/VRFConsumerBase.sol";

contract RandomNumberConsumer is VRFConsumerBase {
    
    bytes32 public keyHash;
    uint256 public fee;
    uint256 public randomResult;
    
    constructor() VRFConsumerBase(
            0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9, // VRF Coordinator
            0xa36085F69e2889c224210F603D836748e7dC0088  // LINK Token
        ) public
    {
        keyHash = 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4;
        fee = 0.1 * 10 ** 18; // 0.1 LINK
    }
    

    function getRandomNumber(uint256 userProvidedSeed) public returns (bytes32 requestId) {
        return requestRandomness(keyHash, fee, userProvidedSeed);
    }

    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
        randomResult = randomness.mod(50).add(1);
    }
}

when i click on getRandomNumber, i always get this error : Error encoding arguments: Error: invalid BigNumber string (argument="value", value="", code=INVALID_ARGUMENT, version=bignumber/5.0.8)

and with the fulfillRandomness, i get this error : Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.0.5)


Solution

  • Add some seed number into the function, and then click it.

    Also, be sure to fund it with LINK.

    Also, fulfillRandomness is only callable by the Chainlink VRF, so no worries on that part.

    enter image description here