我想通过 Chainlink VRF 获得一个随机数,但是想要在同一笔交易中获得,如果我调用 finishLoterya
,就无法获得随机数,如果是分别调用 getRandomeWords
和 getFinalNumbers
,就可以得到结果,这是什么原因?
contract Loterya is Ownable {
uint256[] public numbers;
uint256[] public randomWords;
uint256 public requestId;
function finishLoterya () public {
requestId = getRandomWords(5);
getFinalNumbers(requestId);
}
function getRandomWords (uint32 _numWords) internal returns (uint256) {
return randomNumberOracle.requestRandomWords(_numWords);
}
function getFinalNumbers (uint256 _requestId) internal {
(, randomWords) = randomNumberOracle.getRequestStatus(_requestId);
}
}