WAGMI, Keep Buidling!
When dealing with computers, randomness is an important but difficult issue to handle due to a computer's deterministic nature. This is true even more so when speaking of blockchain because not only is the computer deterministic, but it is also transparent. As a result, trusted random numbers cannot be generated natively in Solidity because randomness will be calculated on-chain which is public info to all the miners and the users.
So we can use some web2 technologies to generate the randomness and then use them on-chain.
Hardhat (Solidity)
Polygon (Mumbai testnet)
Chainlink VRF
- An oracle sends data from the outside world to a blockchain's smart contract and vice-verca.
- Smart contract can then use this data to make a decision and change its state.
- They act as bridges between blockchains and the external world.
- However it is important to note that the blockchain oracle is not itself the data source but its job is to query, verify and authenticate the outside data and then futher pass it to the smart contract.
Let's start building ๐
Chainlink VRF's are oracles which used to generate random values. These values are verified using cryptographic proofs. These proofs prove that the results weren't tampered or manipulated by oracle operators, users, miners etc. Proofs are published on-chain so that they can be verified. After there verification is successful they are used by smart contracts which requested randomness.
Complete track for learning Web3 and make these amazing projects
For more examples and usage, please refer to the Wiki.
Follow the above link for complete setup!