import { createRpcClient, createWalletRpcClient } from './chain-config.js'; import type { PublicClient, WalletClient } from 'viem'; export { createRpcClient, createWalletRpcClient }; export async function getBalance( client: PublicClient, address: `0x${string}` ): Promise { return await client.getBalance({ address }); } export async function getTokenBalance( client: PublicClient, token: `0x${string}`, address: `0x${string}` ): Promise { const balance = await client.readContract({ address: token, abi: [ { name: 'balanceOf', type: 'function', stateMutability: 'view', inputs: [{ name: 'account', type: 'address' }], outputs: [{ name: '', type: 'uint256' }], }, ], functionName: 'balanceOf', args: [address], }); return balance as bigint; } export async function waitForTransaction( client: PublicClient, hash: `0x${string}`, confirmations: number = 1 ): Promise { await client.waitForTransactionReceipt({ hash, confirmations }); }