RPS Labs
  • 👋Welcome to RPS Labs
  • 📋Table of Contents
  • Overview
    • 💡What we do
  • ✌️Using Lotto SDK
    • For Users
      • Case Studies
    • For Developers
      • 💸Pricing
      • 🧰SDK Docs
        • Getting Started
        • UI Components
        • Hooks
      • 💻API Docs
        • Raffle info
        • Users
        • Pot
      • 📃Smart Contracts
        • RPS Raffle
        • RPS Router
        • Configurable Raffle Parameters
        • Fund Management
        • Deployment Guide
        • Security Considerations
      • ⛓️Supported Chains
  • RESOURCES
    • 🙋‍♂️Contact & Social Links
    • ❓FAQ
    • 🖌️Brand Assets
  • COMING SOON
    • DailyGM!
    • Hypercluster
Powered by GitBook
On this page
  1. Using Lotto SDK
  2. For Developers
  3. SDK Docs

Hooks

Last updated 1 year ago

RPS SDK comes with powerful hooks to make accessing RPS data simple and efficient.

Our hooks are built on top of , a high-performance, lightweight data-fetching library. By utilizing SWR, you gain access to efficient request caching, request batching, and a host of robust features developed and tested by the SWR team. This means you can seamlessly incorporate these hooks into your components without concerns about performance bottlenecks or duplicate network requests. Moreover, you have the flexibility to customize SWR's configuration options for each of these SWR-powered hooks. Below, we outline the key properties returned by each of these hooks:

  • response: This property contains the response obtained from the API.

  • data: You can access the data extracted from the API response through this property.

  • mutate: We expose SWR's mutate function, enabling you to efficiently refresh the data when needed.

  • error: If there is an issue or error with the API request, you will find the details here.

  • isValidating: This property allows you to check if there is an ongoing request or revalidation process.

useTicketPrice
import { useTicketPrice } from '@rps-labs/lotto-sdk';

const { data: ticketPrice } = useTicketPrice()

Use this hook to fetch the ticket price in eth and wei using the ticket price endpoint

usePotInfo
import { usePotInfo } from '@rps-labs/lotto-sdk';

const { data: potInfo } = usePotInfo()

Use this hook to fetch the current pot ID, size, limit and ticket number using the current pot info endpoint

useLeaderboard
import { useLeaderboard } from '@rps-labs/lotto-sdk';

const { data: leaderboard } = useLeaderboard()

Use this hook to fetch all wallet addresses in a current pot sorted by their number of tickets using the Get pot leaderboard endpoint.

useTickets
import { useTickets } from '@rps-labs/lotto-sdk';

const { data: tickets } = useTickets()

Use this hook to fetch all tickets a user has in the current pot using the Get All Tickets endpoint

usePreviousWinners
import { usePreviousWinners } from '@rps-labs/lotto-sdk';

const { data: previousWinners } = usePreviousWinners()

Use this hook to fetch all users that won the raffle in the past and info related to their pots using the Get previous winners endpoint.

✌️
🧰
SWR