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: publication.id,  });
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;
  return (    <div>      <p>Publication: {data.publication.id}</p>
      {data.revenue.length ? (        data.revenue.map((revenue, index) => <RevenueCard key={index} revenue={revenue} />)      ) : (        <p>No revenue.</p>      )}    </div>  );}
function RevenueCard({ revenue }: { revenue: RevenueAggregate }) {  const erc20 = erc20Amount(revenue.total);  const rate = revenue.total.rate ? fiatAmount(revenue.total.rate) : null;
  return (    <div>      <p>{`Currency: ${erc20.asset.name}`}</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: profile.id,  });
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;
  return (    <div>      {data.map((item) => {        return (          <>            <p>Publication: {item.publication.id}</p>
            {item.revenue.length ? (              item.revenue.map((revenue, 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.