1.0 React Hooks

Overview

Our React Hooks library uses react-query under the hood & will expose request parameters & response objects that mimic react-query functionality. For instance, in the request parameters you can pass the { enabled: boolean } object and other request parameters found in react-query's documentationarrow-up-right. The response objects will also mimic react-query with { data, isLoading, isSuccess } etc.

circle-info

Since we are mimicking react-query Reveel's SDK integration should feel familiar to many react devs. This also means we are essentially mimicking the request parameter & response objects used by wagmiarrow-up-right which should also feel familiar to web3 Devs.

Functions with example uses are shown below. All the examples below use wagmi functions alongside @r3vl/sdk, but this is not a requirement. Notably, the following example is using wagmi 0.10.8

Integrating the sdk into your frontend

Add the package to your frontend app:

yarn add @r3vl/sdk

--------- or ---------

npm install @r3vl/sdk

Add the provider to your frontend (below is a next.js example):

import { R3vlProvider, createClient as r3vlCreateClient } from "@r3vl/sdk";
import { WagmiConfig, createClient } from "wagmi";

const r3vlClient = r3vlCreateClient();
const wagmiClient = createClient({
  // per wagmi instructions: https://wagmi.sh/examples/connect-wallet
});
const App = ({ Component, pageProps }: AppProps) => {
  return (
    <WagmiConfig client={wagmiClient}>
      <R3vlProvider client={r3vlClient}>
        <Component {...pageProps} />
      </R3vlProvider>
    </WagmiConfig>
  )
}

Creating Revenue Path (code subject to change)

At the moment, @r3vl/sdk is compatible with the following chains:

  • Ethereum (mainnet & goerli)

  • Polygon (mainnet & mumbai)

  • Arbitrum (one & testnet)

  • Optimism (mainnet & goerli)

  • Aurora (mainnet & testnet)

Here a live example of a NextJS implementation of the R3VL SDK

Withdrawing From Revenue Path

Get Revenue Path Balances

circle-info

a simple hook to display a user's available balances

Get Revenue Path Tiers

circle-info

a simple hook to fetch tier data from an existing revenue path

Updating Revenue Path

circle-info

hook to update an existing revenue path in case user's wallet owns that revenue path and it's mutability is enabled

Last updated