Comment on page
Using the SDK
Randcast SDK is a set of smart contracts, libraries, scripts, and examples that can be used to build a DApp or Web3 game that requires randomness. The SDK is designed to be flexible and extensible. The SDK is written in Solidity and can be used in any EVM-compatible blockchain. It aims to help request randomness as well as consume randomness in a secure and easy way. In the next sections, we will introduce how to write a consumer contract, especially for implementing the callback functions.
forge install ARPA-Network/Randcast-User-Contract
You can customize these remappings by creating a
remappings.txtfile in the root of your project.
Now, we can import any of the contracts in
} from "randcast-user-contract/user/GeneralRandcastConsumerBase.sol";
Users can focus on the business logic of their DApp or Web3 game by using the
GeneralRandcastConsumerBase. This base contract provides a simple interface for requesting randomness and receiving results.
When requesting randomness, we provide three types of randomness:
For experienced developers, you can directly inherit the
BasicRandcastConsumerBasecontract to leverage a more flexible interface for requesting randomness. You can use this contract to request randomness in any way you want. See
AdvancedGetShuffledArrayExamplefor an example.
WARNING: You MUST restrict access to the function that requests randomness in your consumer contract. Otherwise, anyone can call this function and use your subscription to pay for randomness requests.