TokenProvider

A React context provider component that supplies Token-related data to its child components.

This component serves as a wrapper around the TokenProviderContext.Provider and passes the provided token data down to all of its child components through the context API.

Example

Basic usage

import { TokenProvider, TokenIcon, TokenName } from "thirdweb/react";
import { ethereum } from "thirdweb/chains";
<TokenProvider address="0x..." client={...} chain={ethereum}>
<TokenIcon />
<TokenName />
</TokenProvider>

This component also works with native token!

import { NATIVE_TOKEN_ADDRESS } from "thirdweb";
import { ethereum } from "thirdweb/chains";
<TokenProvider
address={NATIVE_TOKEN_ADDRESS}
chain={ethereum}
client={client}
>
<TokenSymbol /> // "ETH"
</TokenProvider>;
function TokenProvider(
props: PropsWithChildren<TokenProviderProps>,
): Element;

Parameters

Type

let props: PropsWithChildren<TokenProviderProps>;

Returns

let returnType: Element;