Guides

useCurrencies

useCurrencies is a React Hook that returns the list of ERC20 supported by the Lens Protocol.

const { data, loading } = useCurrencies();

Usage

When configuring Collect Modules and Follow Modules that involve a fee you need to specify an amount which requires to specify the corresponding ERC20 accepted as fee.

The Lens SDK abstracts away these details and all it asks in its input data are instances of an Amount class. To instantiate an Amount you need to provide a string with the amount (as human readable string) and a reference to the correct Erc20 which is a type that encapsulates currency details (ERC20 included).

When invoked the useCurrencies hook interrogates the Lens API to retrieve the list of supported ERC20s and returns a list of Erc20.

You can call useCurrencies to populate for example a drop-down that let the user select which currency to use to configure a fee.

import { useCurrencies } from '@lens-protocol/react-web';


function CurrencyDropdown() {
  const { data, loading } = useCurrencies();
  
  if (loading) return null;

  return (
    <select>
     {
       data.map(currency => (
         <option value={currency.address}>{currency.symbol}</option>
       )
     }
   </select>
  )
}

Reference

useCurrencies()

const { data, loading } = useActiveProfile();

Parameters

  • useCurrencies does not take any parameters.

Returns

  • data array of Erc20
  • loading a flag that let you determine if data is ready to be read.