Reveel Protocol v2 Documentation
  • πŸš€Reveel Protocol - Introduction
  • 🏁Getting Started
    • Creating a Revenue Path
    • Adding Revenue Path Tiers
    • Viewing your Revenue Path
    • Withdrawing Funds
    • Revenue Path Dashboard
    • Updating your Revenue Path
    • Selecting a Network
  • βš—οΈProtocol Concepts
    • Tiers
    • Mutable Revenue Paths
    • Path Manager
    • Platform Fee
    • Meta Transactions
  • πŸ§‘β€πŸŒΎSDK
    • Overview
    • 1.0 React Hooks
    • 2.0 Async Javascript
    • 3.0 Data API
  • NFT Marketplace Integrations
    • Lens
    • Zora
    • Foundation
    • OpenSea
    • Manifold
    • Decent
    • Vol FM
  • ♾️Revenue Share Use Cases
    • Recoup Advance
    • Primary vs. Secondary Splits
    • Revenue Milestone
    • Cap Earnings
Powered by GitBook
On this page
  • Creating Revenue Path (code subject to change)
  • Withdrawing From Revenue Path
  • Get Revenue Path Balances
  1. SDK

2.0 Async Javascript

Previous1.0 React HooksNext3.0 Data API

Last updated 1 year ago

Creating Revenue Path (code subject to change)

see for example createArgs parameters

import { R3vlClient } from "@r3vl/sdk";
import { ethers } from "ethers";

interface ICreateArgs {
  addressList: string[][];
  distributionsList: number[][];
  tokenList: string[];
  limitSequence: ethers.BigNumberish[][];
  pathName: string;
  isImmutable: boolean;
}

export const CreatePathButton = ({ createArgs }: { ICreateArgs }) => {
    
    const handleSubmit = async () => {
        client = new R3vlClient.v2;
        try {
          await client.createRevenuePath(createArgs);
        } catch (e) {
          console.log(e);
        }
    };
    
    return (
        <button onClick={handleSubmit}>Create Path</button>
    );
};

Withdrawing From Revenue Path

import { R3vlClient } from "@r3vl/sdk";
import { useAccount } from "wagmi";
import { ethers } from "ethers";

export const WithdrawRevenueButton = () => {
    const { address } = useAccount();
    
    const handleWithdraw = () => {
        client = new R3vlClient.v2;
        try {
          await client.withdraw(address);
        } catch (e) {
          console.log(e);
        }
    };
    
    return (
        <button onClick={handleWithdraw}>Withdraw Revenue</button>
    );
};

Get Revenue Path Balances

a simple hook to display a user's available balances

import { useBalances } from "@r3vl/sdk/hooks";
import { useAccount } from "wagmi";
import { ethers } from "ethers";
import { useEffect, useState } from "React";

interface IBalances {
  earnings: number;
  withdrawn: number;
  withdrawable: number;
}

export const DisplayBalances = () => {
    const { address } = useAccount();
    const [balances, setBalances] = useState<IBalances>()
    useEffect(() => {
        client = new R3vlClient.v2;
        try {
          const withdrawn = await client.withdrawn(address);
          const withdrawable = await client.withdrawable(address);
          const earnings = withdrawn + withdrawable;
          setBalances({earnings, withdrawn, withdrawable});
        } catch (e) {
          console.log(e);
        }
    }, []);
    
    return (
        // earnings - withdrawn = withdrawable
        <div display="flex">
            {!!balances && (
                <div className="total-earnings">{balances.earnings}</div>
                <div className="total-withdrawn">{balances.withdrawn}</div>
                <div className="total-withdrawable">{balances.withdrawable}</div>
            )}
        </div>
    );
};
πŸ§‘β€πŸŒΎ
here