# Using the SDK

## Introduction

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.

We recommend using [Foundry](https://github.com/foundry-rs/foundry) to manage the dependencies, compile the project, run tests, and deploy.

## Installation

```bash
forge install ARPA-Network/Randcast-User-Contract
```

## Remapping Dependencies

You can customize these remappings by creating a `remappings.txt` file in the root of your project.

```
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
randcast-user-contract/=lib/Randcast-User-Contract/contracts/
```

## Usage

Now, we can import any of the contracts in `Randcast-User-Contract/contracts` like so:

```solidity
import {
    GeneralRandcastConsumerBase,
    BasicRandcastConsumerBase
} 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: `Randomness`, `RandomWords`, and `Shuffling`.

For experienced developers, you can directly inherit the `BasicRandcastConsumerBase` contract to leverage a more flexible interface for requesting randomness. You can use this contract to request randomness in any way you want. See `AdvancedGetShuffledArrayExample` for 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.*

## Examples

See [consumer-contract-examples](https://docs.arpanetwork.io/randcast/using-the-sdk/consumer-contract-examples "mention") for more details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arpanetwork.io/randcast/using-the-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
