Collect Revenues

Learn how to retrieve information about the revenue generated from the collections of your publications.

Collectible publications can generate revenue for their creators and associated wallets. The distribution of this revenue is determined by the settings of the Collect Actions that were attached to the publication at the time of its creation.

Publication Revenues

Retrieve revenues generated from a given Publication.

You can use the useRevenueFromPublication hook to get revenue from a single publication.

import {  Amount,  AnyPublication,  Asset,  erc20Amount,  Erc20Amount,  fiatAmount,  FiatAmount,  RevenueAggregate,  useRevenueFromPublication,} from '@lens-protocol/react-web';
function RevenueFromPublication({ publication }: { publication: AnyPublication }) {  const { data, error, loading } = useRevenueFromPublication({    for:,  });
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;
  return (    <div>      <p>Publication: {}</p>
      {data.revenue.length ? (, index) => <RevenueCard key={index} revenue={revenue} />)      ) : (        <p>No revenue.</p>      )}    </div>  );}
function RevenueCard({ revenue }: { revenue: RevenueAggregate }) {  const erc20 = erc20Amount(;  const rate = ? fiatAmount( : null;
  return (    <div>      <p>{`Currency: ${}`}</p>      <p>{`Value: ${formatAmount(erc20)}`}</p>      {rate && <p>{`Fiat value: ${formatFiatAmount(erc20, rate)}`}</p>}    </div>  );}
function formatAmount(amount: Amount<Asset>): string {  return `${amount.toSignificantDigits()} ${amount.asset.symbol}`;}
function formatFiatAmount(amount: Erc20Amount, rate: FiatAmount): string {  const fiat = amount.convert(rate);  return formatAmount(fiat);}

Note that we use erc20Amount and fiatAmount helpers to convert the amounts returned from the API into objects. These objects provide useful methods for comparing and formatting the amounts.

Profile Collect Revenues

Retrieve all revenues a Profile has generated from their publications.

You can use the useRevenueFromPublications hook to get revenues from all publications.

In the following example, we utilize the RevenueCard component, which was introduced in the previous example.

import { Profile, useRevenueFromPublications } from '@lens-protocol/react-web';
function RevenueFromPublications({ profile }: { profile: Profile }) {  const { data, error, loading } = useRevenueFromPublications({    for:,  });
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;
  return (    <div>      { => {        return (          <>            <p>Publication: {}</p>
            {item.revenue.length ? (    , index) => <RevenueCard key={index} revenue={revenue} />)            ) : (              <p>No revenue.</p>            )}          </>        );      })}    </div>  );}

The hook yields a PaginatedReadResult<PublicationRevenue[]>. For more information on pagination, refer to this guide.