我正在尝试使用 Chainlink VRF 获得一个随机数,所以您好,请逐步遵循此演示:https ://www.youtube.com/watch?v=JqZWariqh5s
这是我在 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);
}
}
当我单击getRandomNumber时,我总是收到此错误: 错误编码参数:错误:无效的 BigNumber 字符串(argument="value",value="",code=INVALID_ARGUMENT,version=bignumber/5.0.8)
并且使用fulfillRandomness,我得到这个错误: 错误编码参数:错误:无效的arrayify值(argument =“value”,value =“”,code = INVALID_ARGUMENT,version = bytes / 5.0.5)