@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
50 lines • 2.02 kB
TypeScript
import { Account, Address, Chain, ParseAccount, RpcSchema, Transport } from "viem";
import { AvalancheClient, AvalancheClientConfig } from "./types/createAvalancheClient.js";
/**
* Creates an Avalanche Client with a given transport configured for a Chain.
*
* The Avalanche Client is an interface to interact with the Avalanche network through various JSON-RPC API methods.
* It provides access to multiple sub-clients for different chains and APIs:
* - P-Chain (Platform Chain)
* - X-Chain (Exchange Chain)
* - C-Chain (Contract Chain)
* - Admin API
* - Info API
* - Health API
* - Index API
*
* @param parameters - {@link AvalancheClientConfig}
* @returns An Avalanche Client with access to all sub-clients. {@link AvalancheClient}
*
* @example
* ```ts
* import { createAvalancheClient} from '@avalanche-sdk/client'
* import { avalanche } from '@avalanche-sdk/client/chains'
*
* const client = createAvalancheClient({
* chain: avalanche,
* transport: {
* type: "http",
* },
* })
*
* // Access different chain clients
* const pChainClient = client.pChain
* const xChainClient = client.xChain
* const cChainClient = client.cChain
*
* // Access API clients
* const adminClient = client.admin
* const infoClient = client.info
* const healthClient = client.health
* const indexPChainBlockClient = client.indexPChainBlock
*
* // Get the latest block number
* const blockNumber = await client.pChain.getBlockNumber()
*
* // Get base fee
* const baseFee = await client.getBaseFee()
* ```
*/
export declare function createAvalancheClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined, raw extends boolean = false>(parameters: AvalancheClientConfig<transport, chain, accountOrAddress, rpcSchema, raw>): AvalancheClient<transport, chain, ParseAccount<accountOrAddress>>;
//# sourceMappingURL=createAvalancheClient.d.ts.map