useRootStorage
Props
Name
Type
Description
Return Type
Name
Type
Description
Basic Usage
import { useContract, useRootStorage } from 'typink';
import { Psp22ContractApi } from './types/psp22';
function TokenInfo() {
const { contract } = useContract<Psp22ContractApi>('psp22-token');
const { storage, isLoading, refresh } = useRootStorage({ contract });
if (isLoading) return <div>Loading token info...</div>;
return (
<div>
<p>Name: {storage?.name}</p>
<p>Symbol: {storage?.symbol}</p>
<p>Decimals: {storage?.decimals}</p>
<p>Total Supply: {storage?.data?.totalSupply?.toString()}</p>
<button onClick={refresh}>Refresh</button>
</div>
);
}Last updated