Skip to main content
Use this page when you want the fastest path to a working consumer contract on Abstract. Choose the path that matches your starting point:
  • New project: scaffold a Foundry starter that already includes an example consumer contract.
  • Existing project: wire the hosted roll.codes coordinator into your current Solidity app.

New projects

The starter CLI generates a Foundry project with:
  • src/DiceDuelConsumer.sol
  • test/DiceDuelConsumer.t.sol
  • script/DeployDiceDuelConsumer.s.sol
  • remappings and Foundry config for Abstract
The generated consumer already requests randomness with requestRandomNumberWithTraceId(...) and receives it in randomNumberCallback(...).
1

Build the starter CLI

The CLI source currently lives in this repository.
2

Scaffold a starter project

Run the generator from the CLI package directory:
This creates ./my-game with the example consumer already wired to the public IVRFSystem interface.
3

Build and test the generated project

4

Configure the hosted coordinator and deploy

See Deployed addresses for the current network-specific coordinator status and addresses.
If you want the full CLI surface, including --dir, --force, and --skip-install, see CLI reference.

Integrating into an existing project

Use this path if you already have a Foundry project and only need to add roll.codes support.
1

Install the dependency

2

Add remappings

Your project should include:
3

Request a random number

Import the public interfaces, store the hosted coordinator address, then request randomness by paying requestFee().
4

Handle the callback safely

Every request is delivered asynchronously. Restrict the callback to the hosted coordinator and settle against stored request state.
5

Deploy only your consumer

Set the hosted coordinator address for the same network as your RPC URL:
Then deploy your own consumer contract with your normal Foundry script flow, using --account deployer when you broadcast.
requestRandomNumberWithTraceId is payable on roll.codes, so callers must send the exact value returned by requestFee().
Prefer a Foundry keystore account over exporting plaintext private keys. Import once with cast wallet import and reuse that account name with forge script --account ....
Requests delivered from the same drand round receive the same base randomNumber. If your app needs a unique value per request within that same round, derive one locally from requestId and randomNumber.

Verify the result

You should end with:
  • a deployed consumer contract
  • a configured roll.codes coordinator address in your deployment inputs
  • a request path that pays requestFee()
  • a callback that only accepts the hosted coordinator

Next steps

Integration pattern

Copy a fuller consumer example with request storage and settlement guards.

Coordinator reference

Keep the request function, fee call, and callback interface beside you while implementing.

Troubleshooting

Fix fee mismatches, unauthorized callbacks, and pending requests.

CLI reference

Review the starter generator flags and output files.
Last modified on March 9, 2026