# Migrate from D20DAO

The Randoo coordinator serves D20DAO's `ID20VRF` interface. A consumer built on D20DAO's `D20VRFConsumer` runs on Randoo when you deploy it with `0xC66eB2e7EE91145875000Ad46B55600000000001` as its coordinator. Its requests, callbacks and mapped results keep working, and nothing else in the contract changes. You pay each request in the network's native token.

The interface is live on Robinhood, Robinhood Testnet, Base, Base Sepolia, Ronin Mainnet and Ronin Saigon, at the same address on each. [Contracts](/docs/contracts) lists their chain IDs. [VRF on Robinhood](/docs/robinhood) compares D20DAO, Randoo and RH-VRF side by side.

| | D20DAO | Randoo |
| --- | --- | --- |
| Coordinator | `0xEc8b95B168c87294c45727Bd2ac903d09316D132` (testnet `0x2f26513DE4Ed388947f5d22FD395D5E06f472f05`) | `0xC66eB2e7EE91145875000Ad46B55600000000001` on every network |
| Base contract | `D20VRFConsumer` | `D20VRFConsumer`, unchanged |
| Calls | `quoteFee`, `requestRandomness`, `requestMappedRandomness`, `getMappedResult` | The same |
| Callback | `rawFulfillRandomness(uint256 requestId, bytes32 randomness)` | The same |
| Callback gas | 30,000 to 1,000,000 | 30,000 to 2,500,000, charged as at least 50,000 |

## Consumer

Deploy your consumer with one change, its coordinator address:

```solidity The one line that changes
DiceConsumer dice = new DiceConsumer(0xC66eB2e7EE91145875000Ad46B55600000000001);
```

Randoo's tests deploy D20DAO's three SDK examples, `DiceConsumer`, `RaffleConsumer` and `LootDropConsumer`, compiled from D20DAO's own files, and fulfill each one. This is the dice example as D20DAO ships it:

```solidity DiceConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {D20VRFConsumer} from "@d20dao/vrf-sdk/contracts/D20VRFConsumer.sol";
import {ID20VRF} from "@d20dao/vrf-sdk/contracts/interfaces/ID20VRF.sol";
import {D20VRFRequests} from "@d20dao/vrf-sdk/contracts/libraries/D20VRFRequests.sol";

/// @notice One d20 per player, paid by the player. Swap `d20` for `d6` or `coinFlip` and nothing else moves.
contract DiceConsumer is D20VRFConsumer {
    using D20VRFRequests for ID20VRF;

    /// The callback does two storage writes and nothing else, and the fee grows with this number.
    uint32 private constant CALLBACK_GAS = 100_000;

    struct Roll { address player; bytes32 word; bool ready; }
    mapping(uint256 => Roll) public rolls;

    error Underpaid(uint256 quoted, uint256 sent);
    error ChangeRefused();
    error UnexpectedCallback();
    error NotReady();

    constructor(address coordinator) D20VRFConsumer(coordinator) {}

    function roll() external payable returns (uint256 requestId) {
        ID20VRF rng = ID20VRF(vrfCoordinator);
        // quoteFee prices from block.basefee, so it is exact here and only here. A wallet cannot read it in
        // advance: off-chain it quotes quoteFeeAt(gas, the latest header's baseFeePerGas) plus a buffer and
        // sends that, never through eth_call, where the base fee is reported as 0.
        uint256 fee = rng.quoteFee(CALLBACK_GAS);
        if (msg.value < fee) revert Underpaid(fee, msg.value);
        // The helper pays exactly `fee` out of this contract's balance, which msg.value just funded.
        // The player is the refund address, so if the request expires, refundRequest returns the fee straight to them.
        requestId = rng.d20(D20VRFRequests.Options(keccak256(abi.encode(msg.sender)), CALLBACK_GAS, msg.sender));
        rolls[requestId] = Roll(msg.sender, bytes32(0), false);
        // Hand the player's buffer back now. Left with the coordinator it becomes refund credit they would
        // have to claim in a separate withdrawRefundCredit transaction.
        if (msg.value > fee) {
            (bool sent,) = payable(msg.sender).call{value: msg.value - fee}("");
            if (!sent) revert ChangeRefused();
        }
    }

    function _fulfillRandomness(uint256 requestId, bytes32 randomness) internal override {
        Roll storage entry = rolls[requestId];
        // Refuse a request this contract never made, and a repeat of one it already holds. A failed delivery is
        // retried by anyone with retryCallback and a successful one is never repeated; the check costs one read.
        if (entry.player == address(0) || entry.ready) revert UnexpectedCallback();
        // Store, do not compute. The callback runs inside CALLBACK_GAS; work that overruns it fails the
        // delivery, and although the request stays served and paid, someone must retryCallback it.
        entry.word = randomness;
        entry.ready = true;
    }

    /// @return 1 to 20. The coordinator maps the stored word; a losing roll is never re-rolled.
    function result(uint256 requestId) external view returns (uint256) {
        if (!rolls[requestId].ready) revert NotReady();
        return ID20VRF(vrfCoordinator).getMappedResult(requestId)[0];
    }
}
```

## Request

1. The consumer calls `quoteFee(callbackGasLimit)`. It prices at the transaction's gas price, so the quote is exact inside the requesting transaction.
2. The consumer sends at least the quote with `requestRandomness` or `requestMappedRandomness`. Sending less reverts with `InsufficientFee`.
3. One block later the oracle fulfills, and `rawFulfillRandomness(requestId, randomness)` runs. `getMappedResult(requestId)` then returns the mapped result, computed with D20DAO's own `RandomnessMapping` library.

Off chain, `quoteFeeAt(callbackGasLimit, gasPrice)` returns the same price for a gas price you pass. Pass the price your transaction will pay, base fee plus tip, not the bare base fee that D20DAO's `quoteFeeAt` takes.

## Differences from D20DAO's coordinator

- Requests never expire. Randoo's oracles keep trying until they fulfill, so `onRefund` never fires, and `refundRequest` and `retryRefundCallback` do not exist.
- Unused prepayment comes back at fulfillment. The coordinator sends it to your refund address. If that address cannot receive the native token, it becomes a credit the address withdraws with `withdrawRefundCredit`.
- `quoteFee` prices at the transaction's gas price. D20DAO prices at the block's base fee.
- Callback gas from 30,000 to 49,999 is raised to 50,000 and charged as 50,000. The ceiling is 2,500,000.
- `clientSeed` is accepted and ignored. Randoo binds each seed to the request block hash, the request id, your consumer and the oracle's key, so nobody can choose it.
- `retryCallback(requestId, gasLimit)` works as on D20DAO. After a failed callback, anyone can deliver the same stored randomness again, with at least the request's callback gas, until one delivery succeeds.
- The coordinator emits Randoo's events, `RandomSeedRequested` and `RandomSeedFulfilled`, not D20DAO's.

## Randoo vs D20DAO

On Robinhood, a Randoo request costs about $0.040 including gas and a D20DAO request about $0.051. Randoo fulfills in a second or two, while D20DAO waits for a drand round at least 3 seconds after the request. D20DAO is the one to pick if you deploy on Arc, or if you want each result to depend on a public beacon as well as on the provider's own key.

The prices come from Robinhood mainnet on 2026-11-12 at block 112,342,978, with ETH at $2,046, the rate Randoo's coordinator used at that block to convert its fee.

| | Randoo | D20DAO |
| --- | --- | --- |
| Networks | Ronin, Base and Robinhood, with their testnets | Arc and Robinhood, with their testnets ([deployed contracts](https://d20dao.org/docs/deployments)) |
| Cost per request on Robinhood | 0.0000196 ETH (about $0.040) including gas: the $0.035 service fee plus the gas the fulfillment used, averaged over Randoo's two latest Robinhood fulfillments (blocks 111,979,222 and 111,989,857, 250,000 callback gas) | 0.000025 ETH (about $0.051), gas included, from `quoteFee` at 100,000 and at 250,000 callback gas |
| Time to fulfill on Robinhood | 1 to 2 seconds for each of Randoo's 9 latest Robinhood fulfillments | At least 3 seconds: a request waits for the first drand round scheduled 3 or more seconds after its block ([architecture](https://d20dao.org/docs/architecture)) |
| What the random number depends on | Randoo's oracle key, the request block hash, the request id and the consumer, with the VRF proof checked on-chain | D20DAO's key and a drand round, with the round's BLS signature and the VRF proof checked on-chain |
| A request nobody fulfills | Never expires; the oracles keep trying | Refundable after its deadline through `refundRequest` |
| Published load tests | None; the homepage shows live fulfillment times | 1,270 paid requests on Arc Testnet, 2026-09-18 ([benchmarks](https://d20dao.org/benchmarks)) |

D20DAO charges the larger of 0.000025 ETH and 2 × base fee × (405,000 + callback gas), gas included, so its price only rises above the floor when Robinhood's base fee climbs. Randoo's request prepays gas at the price you declare and refunds what the fulfillment does not use; [Fees and failures](/docs/gas) has the formula. The [playground](/playground?network=robinhood) shows both prices live and races the two in one transaction.

## Try it first

Deploy your consumer on Robinhood Testnet (chain 46630) first. The coordinator has the same address there. The [playground](/playground?network=robinhood) races Randoo against D20DAO in one transaction, so you can watch both answer before you switch.

_Updated 2026-11-12._
