PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 183 forks source link

How does our chainlink Keeper trigger fullfillRandomWords? #162

Closed Ahmedborwin closed 1 year ago

Ahmedborwin commented 1 year ago

Hi,

I am wondering how our fullfillRandomWords functions is triggered on our sepolia testnet.

With our Hardhat mockOffchain script we trigger the preform upKeep and then then the fullfillRandomWords.

I think the first part that is confusing me is how an interfaec works. When i look at the interface contract i only see a few functions one of which is the requestRandomWords and no mention of the fullfillRandomWords function.

However, looking at the Sepolia's vrfCoordinatorV2 contract on etherscan i can see the full contract with functions that allw user to requestRandomWords and to fullfillRandomWords.

My questions are (and they might be linked):

How does the logic flow on the vrfCoordinatorV2 contract, so that calling requestRandomWord will utlimatley trigger the fullFillRandomWord function on our Raffle contract?

Having defined i_vrfCoordinator = VRFCoordinatorV2Interface(vrfCoordinatorV2);

When we trigger the requestRandomWords on our Raffle contract: i_vrfCoordinator.requestRandomWords() are we directly triggering the requestRandomWords on the vrfCoordinatorV2 sepolia contract?

I apologise if my question is not clear or succint. Trying to make sense of the unkowns in my own head.

Any help would be much appreciated

Also, if someone can point me towards any material that will help me better understand interfaces, abstract contracts and how they are used, again i would apprecciate this greatly.

Thank you

PS I cannot for the life of me figure out how to get this github post to recognise variable names. If I use the ```Solidity everthing aafter the word interface is purple...