VRF
Last updated
Last updated
Paintswap VRF (Verifiable Random Function) provides secure, provably fair random numbers for smart contracts on the Sonic blockchain. Unlike traditional RNG services, Paintswap VRF uses cryptography and Web3 using Sonic's distributed ledger to prove that the output was determined by the inputs that no one could have manipulated the results.
Thanks to Sonic's innovative Fee Monetization model, we provide secure random number generation with no additional costs beyond standard gas fees.
Fee Structure
Gas fees + ERC20/native token fees
Gas fees only
Tokens Required
Must hold specific tokens
Just network gas token
Fulfillment Time
Multiple blocks/minutes
Sub-second response possible
Subscription Management
Complex subscription system
No subscriptions needed
Cost Predictability
Variable based on token prices
Predictable gas costs only
Smart Contract Architecture
PaintswapVRFCoordinator: Core coordinator contract with UUPS upgradeability
PaintswapVRFConsumer: Abstract base class for contracts requesting randomness
VRF library: Implements cryptographic functions using Secp256k1 and SHA256
Owner Controls: Oracle registration, fee management, parameter tuning
Oracle Worker System
VRF Listener: Monitors blockchain events for randomness requests
VRF Processor: Generates cryptographic proofs and submits transactions
Queue: Maintains workers, request state, and status tracking
Heartbeat System: Ensures oracle health with periodic checks
Security Properties
Cryptographic Verification: Elliptic curve based VRF with on-chain validation
Distributed Processing: Multiple oracles can process requests with locking mechanism
Retry Mechanism: Handles temporary failures with backoff strategy
Import PaintswapVRFConsumer
base contract and inherit from it
Implement _fulfillRandomWords()
callback
Store request context to match responses with requests
Request randomness by calling _requestRandomnessPayInNative()
Process delivered random words in your callback function
Sonic Mainnet
146
Coming soon
Blaze Testnet
57054
0xcCD87C20Dc14ED79c1F827800b5a9b8Ef2E43eC5