ARC / VRF
Verifiable randomness on Arc.
Verifiable random numbers for smart contracts on Arc.
Quickstart
npm i @d20dao/vrf-sdk// 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";
contract Dice is D20VRFConsumer {
mapping(uint256 => bytes32) public results;
constructor(address coordinator) D20VRFConsumer(coordinator) {}
function roll(bytes32 seed) external payable returns (uint256 id) {
id = ID20VRF(vrfCoordinator).requestRandomness{value: msg.value}(seed, 100_000, msg.sender);
}
function _fulfillRandomness(uint256 id, bytes32 word) internal override {
results[id] = word;
}
}
Pass the coordinator below to the constructor and send at least quoteFee(100_000) with roll.
Coordinator
- Arc Mainnet · 5042
0xd20da057469C45928912d983F45790C41e290571· manifest- Arc Testnet · 5042002
0xd20DA0FF9087d053f0291524Eac12abA1ADBd945· manifest
Fee and delivery
- Fee
max(0.02 USDC, 3 × base fee × (300,000 + callback gas))- Delivery
- Measured median 2 seconds for an isolated request on Arc Testnet.
- Refund
- If a request is not fulfilled within 60 seconds, its fee can be refunded to the request's refund address.
Verification
Each 200-block epoch commits one drand round for paid demand; a VRF proof binds a future block. Anyone can replay a result from public data. Full trust model
Questions
- How do I get a random number on Arc?
- Extend D20VRFConsumer with the coordinator 0xd20da057469C45928912d983F45790C41e290571, pay the quoted fee in USDC and call requestRandomness. The random word arrives in _fulfillRandomness.
- What does it cost?
- max(0.02 USDC, 3 × base fee × (300,000 + callback gas)), paid in native USDC by the requesting transaction. Read quoteFee(callbackGasLimit) from the coordinator; the owner sets pricing for future requests.
- Can the result be verified?
- Yes. Each epoch's drand round is verified onchain and each result carries a VRF proof. The Explorer and the SDK replay a request from public chain data.
- Is there a testnet?
- Yes. Arc Testnet, chain 5042002, coordinator 0xd20DA0FF9087d053f0291524Eac12abA1ADBd945.
- What if a request is not fulfilled?
- If a request is not fulfilled within 60 seconds, its fee can be refunded to the request's refund address.
- Why not use block.prevrandao?
- On Arc, block.prevrandao always returns 0, so it carries no randomness.