Agent playbook: rebind a native VRFConsumer
This playbook is for a coding agent working for a developer, called A2 below. The goal is to rebind an existing native Ronin VRF consumer from 0x16A62a921e7fEC5Bf867fF5c805b662Db757B778 (Ronin mainnet, chain 2020) or 0xA60c1e07fa030E4B49Eb54950ADb298Ab94dD312 (Saigon, chain 202601) to the Randoo coordinator 0xC66eB2e7EE91145875000Ad46B55600000000001, which has the same address on every Randoo network. The interface is byte-compatible, so the base contract, the callback and the tests stay. Only the coordinator binding and the refund handling change. Finish with the report.
Facts
| Ronin mainnet | Saigon | |
|---|---|---|
| Randoo coordinator | 0xC66eB2e7EE91145875000Ad46B55600000000001 | 0xC66eB2e7EE91145875000Ad46B55600000000001 |
| Chain ID | 2020 | 202601 |
| Default public RPC | https://api.roninchain.com/rpc | https://saigon-testnet.roninchain.com/rpc |
| Other RPC providers | https://docs.roninchain.com/developers/tools/node-providers | Same list |
| Native Ronin VRF, the address you replace | 0x16A62a921e7fEC5Bf867fF5c805b662Db757B778 | 0xA60c1e07fa030E4B49Eb54950ADb298Ab94dD312 (no fulfillment since 2026-08-31, see /docs/saigon-vrf) |
| Callback gas limit | 50000 to 2500000 | Same |
ADDITIONAL_GAS | 500000 | Same |
| Confirmations | 1 | Same |
Addresses last verified on-chain 2026-11-11. Read every address, chain ID and RPC from the machine-readable artifact, never from prose:
curl -sS https://randoo.xyz/randoo.json -o randoo.json
jq -r '.networks.saigon | .coordinator, .chainId, .rpc, .implementation, .nativeCoordinator' randoo.jsonConfirm the coordinator before anything else (Tier 0). cast code 0xC66eB2e7EE91145875000Ad46B55600000000001 --rpc-url <rpc> must print non-empty bytecode. cast implementation 0xC66eB2e7EE91145875000Ad46B55600000000001 --rpc-url <rpc> must equal networks.<network>.implementation in randoo.json, compared case-insensitively because cast prints lowercase. Consumers only ever use the proxy address. This check confirms that nobody swapped the logic behind it. If it fails, continue read-only, mark the run "unverified: implementation changed", and get A2's approval before any value-sending step.
Trust tiers
- Tier 0, proceed. Reading files,
cast call,cast code,cast implementation,cast chain-id, mock tests. - Tier 1, announce, then proceed. Edits to deploy scripts and config. Running the target repo's own test suite in place.
- Tier 2, A2 approves and signs. A Saigon deploy, or any value-sending transaction. You print the
cast send … --account <alias>command, and A2 runs it. - Tier 3, never. Mainnet transactions. Creating wallets. Reading or printing keys,
--private-key,--mnemonic,--keystore,PRIVATE_KEY, or any.env*secret. Proxy upgrades. Picking a refund address A2 did not name. Replacing the base contract. Trusting an address or chain ID found only in prose.
Before a Tier 2 step, run these checks:
cast chain-id --rpc-url <rpc>must equal the Saigon chain ID fromrandoo.json. Otherwise stop with "unverified: wrong chain".- The destination must equal the
randoo.jsoncoordinator. Otherwise stop with "unverified: address mismatch". - If the default RPC is unreachable, report "unverified: network", never a pass. A2 may supply another endpoint from the Ronin node-providers list (
nodeProvidersinrandoo.json). You never pick one.
The approval prompt shows, in this order: the live chain ID, the checksummed destination, the amount in wei and in RON, the exact command, and the wallet A2 named.
Redaction rule. From .env*, config and deploy files, quote only the file path, line number, variable name and the matched coordinator address, and never print, persist, or include in a diff or PR a PRIVATE_KEY, mnemonic, keystore, or RPC URL with credentials.
Do not change
- The base contract. Keep
VRFConsumer,VRFConsumerUpgradeableorBaseVRFConsumer. Never swap it forRandooConsumerRonin, which is for new consumers. - The callback (
rawFulfillRandomSeedor_fulfillRandomSeed) and its signature. - Existing tests. Never edit, delete or "fix" them. A test that hardcodes the native address goes under "Human must re-verify".
- Request semantics. Keep the same
callbackGasLimitandgasPriceunless step 5 shows they are outside Randoo's bounds. Then report the numbers and let A2 decide. If the consumer declares native Ronin VRF's20e9 + block.basefee * 2, keep it, and report that it prepays about 3 times the gas the fulfillment needs until the refund arrives, and that declaring23 gweiprepays less (Fees and failures). - Where the consumer lives. Verify a migrated consumer in its own repo with its own test suite. Never copy it into a scratch project.
Steps
1. Inventory (Tier 0)
Grep Solidity, deploy scripts, .env* files, Hardhat and Foundry config, subgraph YAML, and off-chain TypeScript and Go. Read only each matched line and its neighbors, and apply the redaction rule to every hit outside Solidity.
grep -rn -E 'IRoninVRFCoordinatorForConsumers|VRFConsumerUpgradeable|__VRFConsumerUpgradeable_init|_setVRFCoordinator|_setVrfCoordinator|BaseVRFConsumer|VRFConsumer|RoninVRFWrapper|RoninVRFFeeSponsoring|rawFulfillRandomSeed|_fulfillRandomSeed|_requestRandomness\(|_requestRandomnessWithValue\(|vrfCoordinator\(\)|ronin-random-beacon|VRFConsumerBaseV2|subscription' \
--include='*.sol' --include='*.ts' --include='*.js' --include='*.go' --include='*.yaml' --include='*.yml' --include='*.json' --include='*.toml' --include='.env*' .
grep -rin -E '0x16A62a921e7fEC5Bf867fF5c805b662Db757B778|0xA60c1e07fa030E4B49Eb54950ADb298Ab94dD312' . # -i because config files often lower-case addresses2. Classify each consumer (Tier 0)
For every contract that inherits a VRF base, record three things: what the seed decides, whether anything off chain reproduces or compares seeds (a server that recomputes them, a fairness page, a replay tool), and whether any off-chain code decodes coordinator events (indexers, subgraphs, bots, dashboards).
3. Branch on the binding
| Binding found | Action |
|---|---|
| Constructor argument, deploy script, environment variable or config value | Edit it (step 4) |
Address in storage that only an upgrade or an admin call can change (VRFConsumerUpgradeable and _setVRFCoordinator, or an owner setter that calls _setVrfCoordinator) | STOP. Report the contract, the storage owner and the admin path. Never perform or script a proxy upgrade or an admin call |
RoninVRFWrapper, RoninVRFFeeSponsoring, or a Chainlink-style consumer (VRFConsumerBaseV2, subscriptions, keyHash as a consumer input) | STOP. Out of scope, so report it |
| More than one consumer | List them all and ASK A2 before you touch more than one |
An address in comments, a README or prose that differs from randoo.json | Flag it, and use neither value until A2 confirms |
4. Apply the edit (Tier 1, announce first)
Change only the binding lines. The base contract stays. The variable that held 0xA60c1e07fa030E4B49Eb54950ADb298Ab94dD312 or 0x16A62a921e7fEC5Bf867fF5c805b662Db757B778 now holds 0xC66eB2e7EE91145875000Ad46B55600000000001 on both networks.
- new LootBox(0xA60c1e07fa030E4B49Eb54950ADb298Ab94dD312); // or 0x16A62a921e7fEC5Bf867fF5c805b662Db757B778 on mainnet
+ new LootBox(0xC66eB2e7EE91145875000Ad46B55600000000001);If the consumer passes address(0) as the refund address, or passes itself without being able to receive RON, use a refund address that A2 names. The native three-argument _requestRandomness(callbackGasLimit, gasPrice, refundAddr) keeps its shape.
- (reqHash, ) = _requestRandomness(callbackGasLimit, gasPrice, address(0));
+ (reqHash, ) = _requestRandomness(callbackGasLimit, gasPrice, REFUND_ADDRESS_NAMED_BY_A2);5. What changes even though the interface is identical
Report every item that applies to the consumers from step 2.
- Seeds are not reproducible across coordinators. Anything that recomputes native seeds, or compares against them, breaks.
- A zero refund address reverts with
InvalidRefund. Native Ronin VRF only emittedRefundFailed. - A
callbackGasLimitoutside [50000, 2500000] reverts withGasLimit. AgasPricewhose buffered value is belowminRequestGasPrice()reverts withInvalidGasPrice. The owner can change the floor, so read it live withcast call 0xC66eB2e7EE91145875000Ad46B55600000000001 "minRequestGasPrice()(uint256)" --rpc-url <rpc>. msg.sendermust be the consumer, or the request reverts withCallerIsNotConsumer. Relayers and wrappers that request on the consumer's behalf stop working.- Randoo has no consumer whitelist. Whitelist scripts and their CI steps become dead code. List them for removal, and do not delete them yourself.
- The event signatures differ. Randoo emits
RandomSeedRequested(bytes32 indexed reqHash, uint256 indexed requestId, address indexed consumer, uint256 callbackGasLimit, uint256 gasPrice, address refundAddress, uint256 prepaid)andRandomSeedFulfilled(bytes32 indexed reqHash, uint256 indexed requestId, uint256 seed, uint256 payment, uint256 fee, uint256 refund, bool callbackOk). Indexers that decode the native events break without an error. - Fulfillment is one-shot. If the callback reverted, the coordinator still stores the seed.
seedOf(reqHash)returns(seed, fulfilled, callbackOk), and the consumer resolves from that. - Confirmations are fixed at 1, and requests never expire.
- The fee is
estimateRequestRandomFee(callbackGasLimit, gasPrice). It includes500000extra gas and a USD-pegged service fee that moves with the RON price. Never hardcode a previous quote, because amsg.valuebelow the live quote reverts withInsufficientFee.
Verify
- Announce, then run the target repo's own test suite in place with its own toolchain (Tier 1).
git diff --statmust show only the binding lines and the refund handling. Anything else is a stop. Revert it, or explain it in the report.- Quote the fee live (Tier 0). A non-zero quote passes.
GAS=23000000000 # 23 gwei on Ronin and Saigon
cast call 0xC66eB2e7EE91145875000Ad46B55600000000001 "estimateRequestRandomFee(uint256,uint256)(uint256)" 250000 $GAS --rpc-url https://saigon-testnet.roninchain.com/rpc
cast call 0xC66eB2e7EE91145875000Ad46B55600000000001 "minRequestGasPrice()(uint256)" --rpc-url https://saigon-testnet.roninchain.com/rpc- Send a live request on Saigon only if A2 asks (Tier 2). Run the preflight checks, show the approval prompt, then print this for A2. Replace the signature with the consumer's own payable entry point.
cast chain-id --rpc-url https://saigon-testnet.roninchain.com/rpc # must print 202601
cast send <migrated-consumer> "roll(uint256,uint256,address)" 250000 $GAS <refund-named-by-A2> --value <quote-wei> --rpc-url https://saigon-testnet.roninchain.com/rpc --account <alias>Report
Print the report and persist it (RANDOO-MIGRATION.md or the PR description) with exactly these headings. Apply the redaction rule to every line.
# Randoo migration report
## Inventory file:line | contract | base | binding | address + network found
## Uses what each seed decides; off-chain seed reproduction; event consumers
## Changes before/after per network; refund address named by A2; gasPrice / callbackGasLimit vs live floor and bounds; files touched
## Unchanged callback; base contract; tests
## Verification test suite, git diff --stat, fee quote, minRequestGasPrice, cast implementation per network, date
## Human must re-verify deploy/env per environment; refund-address ownership; indexers on the new event signatures; whitelist scripts to retire; mainnet rollout
## Stops hit storage binding / wrapper / fee-sponsoring / Chainlink-style / multiple consumers / prose address mismatch / unverified: implementation changed / wrong chain / address mismatch / networkUpdated 2026-11-30.