1

Chainlink VRF is a service using the VRF(Verifiable random function) to generate verifiable randomness on-chain, a smart contract supplies a seed (which should be unpredictable to the oracles to whom it is provided), and the seed in turn is used to generate a random number that is sent back to the contract.

I read documents and some codes, function RequestRandomWords in smart contract VRFCoordinator supplies preseed to event log. Then Oracle node takes the preseed and a blockhash as input to generate a seed for VRF. At last, VRF uses the seed and its private key to generate verifiable randomness.

My question is:

Which blockhash is used to generate seed in VRF? It looks like the next block after the block where VRF request was made but I do not see the details in document.

Thanks in advance.

1 Answer 1

0

In its source code, see VRFCoordinatorV2#getRandomnessFromProof:


bytes32 blockHash = blockhash(rc.blockNum);
if (blockHash == bytes32(0)) {
  blockHash = BLOCKHASH_STORE.getBlockhash(rc.blockNum);
  if (blockHash == bytes32(0)) {
    revert BlockhashNotInStore(rc.blockNum);
  }
}

The hash of the block which contains the request, is used.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.