Currencies

Discover how currencies function within the Lens ecosystem.


Get Currencies

Discover how to fetch all supported currencies.

The useCurrencies hook allows you to retrieve a list of all supported currencies.

import { Erc20, useCurrencies } from '@lens-protocol/react-web';
export function ListCurrencies() {  const { data, error, loading } = useCurrencies();
  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error listing currencies: {error.message}</p>;
  return (    <ul>      {data.map((currency: Erc20) => (        <li key={currency.address}>          {currency.symbol} - {currency.address}        </li>      ))}    </ul>  );}

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

New Currency

You can register any ERC20 currency by simply passing its address to the registerErc20Currency() function:

function registerErc20Currency(address currencyAddress);

Registering a currency simply indicates its availability and triggers an event that the Frontends, Lens API, and users can track to see which currencies are available.

During the registration process, the currency's decimals, name, and symbol are retrieved.

The registration of a currency triggers an event:

event erc20CurrencyRegistered(  address indexed erc20CurrencyAddress,  string name,  string symbol,  uint8 decimals,  uint256 timestamp);

A new currency will also be automatically registered the first time it is used with any of the modules, such as the follow, reference, or publication action modules.