Token Operations
Methods
Method
Description
Signer
Usage
Read Balance and Allowance
import { ethers } from 'ethers';
import { ThetanutsClient } from '@thetanuts-finance/thetanuts-client';
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
const client = new ThetanutsClient({ chainId: 8453, provider });
const usdcAddress = client.chainConfig.tokens.USDC.address;
const userAddress = '0xYourAddress';
// Get token balance
const balance = await client.erc20.getBalance(usdcAddress, userAddress);
console.log(`Balance: ${ethers.formatUnits(balance, 6)} USDC`);
// Get token decimals (cached after first call)
const decimals = await client.erc20.getDecimals(usdcAddress);
console.log(`Decimals: ${decimals}`); // 6
// Check allowance before a fill or RFQ
const spender = client.chainConfig.contracts.optionBook;
const allowance = await client.erc20.getAllowance(usdcAddress, userAddress, spender);
console.log(`Allowance: ${ethers.formatUnits(allowance, 6)} USDC`);Approve Spending
ensureAllowance (Recommended)
Transfer Tokens
Encode Approval for External Wallets
Token Addresses (Base Mainnet)
Decimal Reference
Token
Decimals
Example
See Also
Last updated

