20 调用chainlinkVRF获取随机数报错revert:0x8129bbcd

提前转账足够的LINK,keyhash、coordinator、Link token地址无误https://docs.chain.link/docs/vrf/v2/subscription/supported-networks/ 请问xdm什么原因?approve?

调用getRandomFromChainlinkVRF错误信息:

execution reverted { "originalError": { "code": 3, "data": "0x8129bbcd", "message": "execution reverted" } }

源码:

// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.14;

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

contract Random is VRFConsumerBase {

    bytes32 internal keyHash;
    uint256 internal fee;
    uint256 public randomNumber;

    // goerli
    // VRF coordinator: 0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D
    // LINK token: 0x326C977E6efc84E512bB9C30f76E30c160eD06FB
    // Key Hash: 0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15
    constructor() 
        VRFConsumerBase(
            0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D,
            0x326C977E6efc84E512bB9C30f76E30c160eD06FB
        )
    {
        keyHash = 0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15;
        fee = 0.25 * 10 ** 18;
    }

    function getRandomFromChainlinkVRF() external returns(bytes32 requestId) {
        require(LINK.balanceOf(address(this)) >= fee, "insufficient fee of LINK");

        // chainlink method
        return requestRandomness(keyHash, fee);
    }

    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
        randomNumber = randomness;
    }
}
请先 登录 后评论

最佳答案 2022-11-13 21:43

提供一个思路, 你可以取查看一下 chainlink 文档里, 关于错误代码 code: 3 的说明。

请先 登录 后评论

其它 1 个回答

宇霍飞
请先 登录 后评论
  • 2 关注
  • 0 收藏,2254 浏览
  • Dezso 提出于 2022-11-10 21:56