Use Solidity Development Tools
Last updated
Last updated
A DApp or Web3 game developer can also interact with the Adapter contract directly. While you can do this in many ways, such as via , , or programmatically, we recommend using from the framework.
Smart Contract development experience in Solidity
Experience with Solidity development toolkit
Install
The instructions below outline the steps a user needs to take in order to request randomness from ARPA Randcast.
You can export several environment variables to streamline the execution of the subsequent commands.
Note: the adapter contract address for the chain you are using can be found on the .
In this step, a subscription is created on the ADAPTER_CONTRACT using the createSubscription
method. Save this subscription ID as it will be used later on. The cast send
command broadcasts a transaction to the Ethereum network.
The subscription id can be retrieved from the contract event logs for subsequent steps.
You can provide the block number from Step 2 to speed up the event search.
Next, fund your subscription with Ethereum. These funds will be used to pay for your subsequent randomness requests.
Note: Recommended eth amounts:
OP Goerli / Mainnet: 0.01 ETH
Sepolia: 0.1 ETH
The user needs to deploy a contract that will consume the randomness provided by Randcast. "forge create" is used to compile and deploy the contract.
In this step, the created consumer contract is added to the adapter contract and linked to your existing subscription via the adapter's addConsumer
method.
We can now request randomness via the user contract with the method getRandomNumber
.
Finally, retrieve the last random number generated with the getLastRandomness
method.
After completing the entire process, you should have a user contract capable of requesting randomness from the Randcast adapter contract.
(Reference: )
(Reference: )
If needed, you can use the to estimate how much ETH each randomness request will cost.
(Reference: )