• useCurrencies is a paginated hook that lets you fetch ERC20 tokens that are enabled on the Lens protocol.

    Pro-tip: use this hook to populate a dropdown menu of currencies to choose from to support for example a collect open action form or setup follow policy fees.

    Parameters

    • args: {
          limit?: InputMaybe<LimitType>;
      } = {}

    Returns PaginatedReadResult<Erc20[]>

    Example

    const { data, loading, error } = useCurrencies();
    

    Example

    function CurrencySelector({ onChange }: { onChange: (currency: Erc20) => void }) {
    const { data: currencies, error, loading } = useCurrencies();

    if (loading) return <Loader />;

    if (error) return <Error message={error.message} />;

    const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
    const currency = currencies.find((c) => c.symbol === event.target.value);
    if (currency) onChange(currency);
    };

    return (
    <select onChange={handleChange}>
    {currencies.map((c) => (
    <option key={c.address} value={c.symbol}>
    {c.name}
    </option>
    ))}
    </select>
    );
    }