This is an automated archive.
The original was posted on /r/ethereum by /u/TwistedMinda on 2023-08-15 01:32:31+00:00.
Hi!
I'm learning solidity, and had a huge struggle for random numbers (with Chainlink VRF).
Maybe it's just me but I don't understand why the oracles need to be set by us necessarily.
Why didn't chainlink provide their own?
The only reason coming to my mind is that there are a lot of networks so it wouldn't be scalable for them.
But why doesn't the community create shareable VRF Oracles?
So for learning purposes I made my own implementation of an abstraction which doesn't require for the end-user to setup an oracle himself.
It works like this:
-
I created a subscription on chainlink
-
I deployed a contract implementing Chainlink VRF contracts
-
I added to it a system to fund the subscription for a given contract to consume
Result for the end-user is:
-
Import my candy functions to retrieve the instance of my deployed "shared oracle"
-
Deploy his own contract with the instance of my candy attached (via constructor)
-
Fund the shared oracle when necessary via a candy function
Steps skipped:
-
Read chainlink documentation
-
Create a subscription
-
Fund the subscription manually or writing a script
-
Manage linkToken Address, vrfCoordinator address, keyHash, subscriptionID…
You just imported a library that allows you to populate secured random numbers.
Check the code:
I suppose that I've missed something, but I don't know what...
Can anybody enlighten me?
Thank you
EDIT: I think I realize now that it's not like with JS and candy libraries everywhere. In blockchain, if your SDK or library is not audited, no one is going to use it anyway
Security first!