提前转账足够的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;
}
}