Using the random beacon on-chain
Last updated
Last updated
Follow this tutorial to learn how to write a smart contract that consumes randomness from Cryptosat's Random Beacon contract.
In this example, we use the example client contract that is available on our Github repository- ClientContract.sol
Go to the compiler tab, as shown below:
Compile ClientContract.sol
Deploy your new contract that consumes our Random Beacon contract:
Click the Deploy & run transactions tab
In the Environment drop-down menu, choose "Injected Provider - MetaMask". Don't forget to approve in the pop-up.
Next to the Deploy button, enter the address of the random beacon:
Velas Mainnet: 0x8f5FE77380B83BaA7365ccc9956EB0594859F9E4
Velas Testnet: 0x4a301BBC5D999C2AAfa01E299C46C654dA6C0fF7
In this example, we'll use the Testnet address:
After you deploy your contract, you can interact with it.
Your request has now been queued and will be submitted to the satellite. The request can take several hours to return to complete.
Once the random number is generated, you can view it by clicking on the random
button.
Click on the requestRandomWord
button to request Space Random Beacon.