14 / 16Module 3: The frontend applicationIntermediate
Part 5: Burning tokens
You can burn tokens through the FT4 session object, which exposes a burn method that removes tokens from the account.
import { useFtSession } from "@chromia/react";import { publicClientConfig as clientConfig } from "@/utils/generate-client-config";interface BurnTokenParams { ticker: string; name: string; amount: number;}function useBurnTokens() { const { data: ftAccounts } = useFtAccounts({ clientConfig }); const { data: session } = useFtSession( ftAccounts?.length ? { clientConfig, account: ftAccounts[0] } : null, ); const burnTokens = useCallback( async (token: BurnTokenParams) => { if (!session) return; try { await session.account.burn(token.ticker, createAmount(token.amount)); onSuccess?.(token); } catch (error) { console.error(error); onError?.(token); } }, [session], ); return burnTokens;}The snippet calls burn on the session's account property, passing the number of tokens to burn.
Written for this site from Chromia’s public course. Code samples are the course’s own.