Description
Getting a random number takes a really long time. After executing the getRandomNumber function, a few minutes go by before I can interact with my random number.
Basically I click getRandomNumber and have to wait 2-3 minutes until the random number shows up in the randomResult variable.
Steps to Reproduce
Additional Information
I am not sure if this behavior is intentional or if I need to change up the code. Ideally I would like to have the value of randomResult once the getRandomNumber function finishes executing. Right now I don't know when the value of randomResult will show up.
Chainlink VRF follows the request and receive cycle of getting a number. This means, it has to look outside the blockchain to get a response.
So, 2 transactions actually take place:
This is necessary to look outside the blockchain like this, otherwise you'll get a deterministic number as opposed to random. The speed at which the random number is returned, is dictated by the block time of the blockchain you're using.
So for Ethereum, the fastest time possible for a Random Number to be returned is 2 * block time, or about 30ish seconds.
On faster chains like polygon, this is drastically lower.