Chainlink VRF v2 shut down on November 30, 2026. Migrating a scheduled draw to Trinity Oracle v2 ======================================================================== This is not an ABI-compatible VRF replacement. Trinity uses a scheduled drand quicknet public randomness pulse and validator-signed delivery, not a VRF coordinator callback. The public randomness pulse is the first drand quicknet round at least 60 seconds after your payment; results usually arrive 2-3 minutes after payment. If one hasn't arrived within 17 minutes of payment, you can claim your full $2.50 back. Set your deadline to payment time + 17 minutes (1020 seconds): that is the delivery window we commit to. A shorter deadline opens the refund earlier, but a refunded order gets no result. Good fit: scheduled raffles, allowlists, tournaments, DAO selection. Not a fit: instant dice or other same-block/instant games. Flat $2.50 per request in Circle USDC or quoted native ETH, plus network gas. No LINK. Prepaid balance is optional. Base (8453) and Arbitrum (42161). Service address on both chains: 0xf6D7335C95239DD697518e575cb0caFD5560099c DELETE THESE LINES ADD THESE LINES ---------------------------------------- ---------------------------------------- import ".../VRFConsumerBaseV2.sol"; import "./ITrinityOracleV2.sol"; contract Draw is VRFConsumerBaseV2 { contract Draw { VRFCoordinatorV2Interface coordinator; ITrinityOracleV2 oracle; uint64 subscriptionId; bytes32 public requestId; bytes32 keyHash; uint256 private sequence; uint32 callbackGasLimit; // No subscription, keyHash, LINK or callback gas. uint16 requestConfirmations; constructor(...) VRFConsumerBaseV2(...) constructor(address verifiedService) { oracle = ITrinityOracleV2(verifiedService); } DELETE: requestId = coordinator.requestRandomWords( keyHash, subscriptionId, requestConfirmations, callbackGasLimit, 1); ADD (ETH prepaid option; contract is the payer): // Restricted funding method: oracle.depositEth{value: msg.value}(); // Freeze entrants and commit draw rules BEFORE requesting. // requestHash is the operator's FIXED source terms, NOT a hash of entrants/rules. // Keep application commitments separately in your contract's immutable draw state. bytes32 sourceTermsHash = 0x3d823e84110f9acee2dc0c0108d24732c8817cff92d838b32ac7e61bcd02f083; requestId = oracle.requestFromCredit( 0, keccak256(abi.encode(address(this), ++sequence)), sourceTermsHash, uint64(block.timestamp + 17 minutes)); // nonce is the per-order salt; the JS SDK generates a cryptographically random // nonce by default. This contract example uses a chain-bound contract sequence. // The deadline is Unix seconds. Use payment time + 17 minutes, as above. // For USDC: approve oracle, depositUsdc(amount), requestFromCredit(1,...). // Or pay per request: request{value: quote + buffer}(...), // requestWithUsdc(...) after approve, or requestWithUsdcPermit(...). // ETH overpayment becomes withdrawable credit, not additional revenue. DELETE: function fulfillRandomWords(uint256 id, uint256[] memory words) internal override { winner = entrants[words[0] % entrants.length]; } ADD: function finishDraw() external { (,,,bytes32 resultHash,,,,,uint64 challengeUntil,,ITrinityOracleV2.State state) = oracle.requests(requestId); require(state == ITrinityOracleV2.State.Delivered || state == ITrinityOracleV2.State.RevenuePaid, "not delivered"); require(block.timestamp > challengeUntil, "challenge still open"); // Also enforce your own one-time finalization guard. winner = entrants[uint256(resultHash) % entrants.length]; } Read status, do not wait for a callback. Delivered is provisional during the challenge window; validator rejection can still refund it. RevenuePaid also retains the result. Unknown/Escrowed/Refunded must not select a winner. The SDK exposes getRequestStatus({provider, chainId, service, requestId}) returning {fulfilled, resultHash, state, asset, amount}; fulfilled includes provisional Delivered, so safety-sensitive applications must also check challengeUntil on-chain. SDK requests default requestHash to V2_SOURCE_TERMS_HASH (also exported as currentSourceTermsHash). Only that supported hash is accepted by the SDK; other hashes would be refunded by the operator, even if accepted by the contract ABI. Do not pass clientSalt: use nonce as the per-order salt, never as a substitute for the fixed requestHash. Preserve application-specific commitments separately. Refunds are pull-based: expired or validator-rejected fees become payer credit in the original asset. claimRefund(requestId) can expire an overdue request and withdraw its fee; withdrawCredit(asset, amount) withdraws available balance. After claimRefund the request is RefundWithdrawn; repeated claims revert. Gas is not refunded. A contract payer must expose its own recovery methods and accept returned ETH. Use access controls; never assume an EOA owns its credit. Do not redraw opportunistically, change frozen entrants, or treat a refund as randomness. Define a deterministic cancellation/recovery policy before opening. See ExampleRaffleConsumer.sol for prepaid ETH and delayed result reading. MockTrinityOracleV2 is OFFLINE ONLY: free requests, unrestricted fulfill(), no real USDC transfers, and no proof/challenge security. Never use it in production.