Implementing in your contract
Last updated
Last updated
It is very easy to implement arrng in your contract. Just follow these steps.
Place the following at the top of your contract in the imports section:
Your contract needs to declare that it is an ArrngConsumer, for example:
You need to pass in the arrng controller address on your constructor call, and pass that to the consumer contract you have imported. First, .
Pass that into your constructor, and on to the consumer as follows:
To make a request you then simply need to call requestRandomWords
on the controller, passing the native token:
Finally, you need to do something with the RNG that will be passed back. To do this, override the internal function fulfillRandomness
as follows:
I love examples!
You need a payable method that you can call to request the RNG, passing in native token for gas and the fee. See for how much to pass.
.