Closed cuckflong closed 2 years ago
Hi,
It looks like you have code from RandomNumberConsumer_unit_test.js
as well as RandomNumberConsumer.sol
If those are the files you are referencing, the difference in the values is because the first request id
transactionReceipt.events[0].topics[1]
is the id of the request to the RandomNumberConsumer
contract
while
requestId = requestRandomness(keyHash, fee);
is the id of the request to the VRF Coordinator
contract.
Closing this for now, but feel free to follow up if more information would help.
Thanks for the response but I thought vrfCoordinatorMock.callBackWithRandomness
is suppose to be called with the id of the request to the VRF Coordinator
contract instead of id of the request to the RandomNumberConsumer
contract
const transaction = await randomNumberConsumer.getRandomNumber()
const transactionReceipt = await transaction.wait(1)
const requestId = transactionReceipt.events[0].topics[1]
const randomValue = 777
await vrfCoordinatorMock.callBackWithRandomness(
requestId,
randomValue,
randomNumberConsumer.address
)
Such that when you try to do something like https://docs.chain.link/docs/chainlink-vrf-best-practices/v1/#having-multiple-vrf-requests-in-flight will work properly
The requestId from
is different to the requestId from the RandomNumberConsumer contract if you log and see them