UNPKG

@avalanche-sdk/client

Version:

A TypeScript SDK for interacting with the Avalanche network through JSON-RPC APIs. This SDK provides a comprehensive set of tools to interact with all Avalanche chains (P-Chain, X-Chain, C-Chain) and various APIs, including wallet functionality for transa

21 lines (17 loc) 643 B
import { readContract } from "viem/actions"; import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient"; import { erc20ABI } from "../abis/erc20"; import { BalanceOfParameters, BalanceOfReturnType } from "./types/balanceOf"; export async function balanceOf( client: AvalancheWalletCoreClient, params: BalanceOfParameters ): Promise<BalanceOfReturnType> { const { contractAddress, address, abi } = params; const balance = await readContract(client, { abi: abi ?? erc20ABI, functionName: "balanceOf", args: [address], address: contractAddress, } as any); return balance as any; }