paintswap
  • Introduction to Paintswap
  • Getting Started
    • Create a Wallet
    • Bridging Funds to Sonic
    • Paintswap
  • Paintswap dApp Suite
    • NFT Marketplace
    • NFT Launchpad
      • Launching your collection
    • Estfor Kingdom
    • VRF
    • Beardies
  • Click royale
  • PAIGE - Paintswap AI Game Engine (coming soon)
  • NFT lending (coming soon)
  • Sonic airdrop orderbook (coming soon)
  • Tokenomics
    • $BRUSH
      • LP/Staking
      • Early Distribution
      • Emissions History
  • NFT Marketplace
    • Introduction & Fees
    • Creating NFTs
      • Contract Factory
      • Bulk Mint
      • Interactive NFTs
      • Metadata
      • Supported NFTs
    • NFT Vaults
    • Trading NFTs
      • Marketplace Mechanics
      • Bulk / Batch Actions
      • Royalties
    • Collections
  • Resources
    • Contracts
    • API Endpoints
    • Discord Sales Bot
    • Media Kit
    • GitHub
    • Bugs & Reports
  • Socials
    • Medium
    • Twitter
    • Discord
    • Telegram
Powered by GitBook
On this page
  • How Paintswap VRF Works
  • Comparison With Traditional Oracle Models
  • System Flow
  • Technical Details
  • Integration Steps
  • npm Package
  • Painswap VRF Portal
  • Media Kit
  1. Paintswap dApp Suite

VRF

PreviousEstfor KingdomNextBeardies

Last updated 12 hours ago

How Paintswap VRF Works

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.

Comparison With Traditional Oracle Models

Feature
Traditional VRF
Paintswap VRF

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

System Flow

  1. Request Random Numbers

    Consumer contract calls requestRandomnessPayInNative() and calculates fee using the Paintswap VRF Coordinator contract.

  2. Event Detection

    VRF Listener detects the RandomWordsRequested event and stores request details in a queue where they can be processed at Sonic speed.

  3. Proof Generation

    A VRF Oracle worker generates a VRF proof using the oracle's private key and prepares the cryptographic verification parameters.

  4. Fulfillment Submission

    Oracle submits the fulfillRandomWords() transaction to the Paintswap VRF contract with the request ID and VRF proof.

  5. On-Chain Verification

    VRF contract verifies the proof, confirms it matches the commitment, and derives provable random word values.

  6. Random Numbers Delivered

    Consumer's rawFulfillRandomWords() callback receives the verified random words and executes logic.

Technical Details

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

Integration Steps

  1. Import PaintswapVRFConsumer base contract and inherit from it

  2. Implement _fulfillRandomWords() callback

  3. Store request context to match responses with requests

  4. Request randomness by calling _requestRandomnessPayInNative()

  5. Process delivered random words in your callback function

Network
Chain ID
VRF Coordinator

Sonic Mainnet

146

Coming soon

Blaze Testnet

57054

0xcCD87C20Dc14ED79c1F827800b5a9b8Ef2E43eC5

npm Package

Painswap VRF Portal

Media Kit

Media Kit
https://www.npmjs.com/package/@paintswap/vrf
Paintswap VRF: Provable Randomnesspaint_Swap
Logo