@avakit/core
The framework-agnostic kernel. Depends only on viem. AvaKit never touches private keys.
Install
$ pnpm add @avakit/core viem@avakit/core is ESM-only — use import, not require. In a CommonJS file, load it with a dynamic await import("@avakit/core"). Requires Node >= 20.11.Chains
Built-in chains and a helper for custom Avalanche L1s, from @avakit/core/chains:
import { fuji, cChain, defineChain } from "@avakit/core/chains";
const myL1 = defineChain({
id: 99999,
name: "My L1",
rpcUrl: "https://my-l1.example/rpc",
explorerUrl: "https://explorer.example",
nativeCurrency: { name: "Token", symbol: "TKN", decimals: 18 },
testnet: true,
});Wallet adapters
Adapters expose an EIP-1193 provider behind a common interface. injectedAdapter() works with Core / MetaMask; web3authAdapter() (from @avakit/core/web3auth) adds social login.
import { injectedAdapter } from "@avakit/core";
import { web3authAdapter } from "@avakit/core/web3auth";
const injected = injectedAdapter();
const social = web3authAdapter({ clientId: process.env.WEB3AUTH_CLIENT_ID! });
const { address, provider } = await social.connect();@web3auth/modal is an optional peer dependency; install it only if you use the social adapter. Get a free client ID at dashboard.web3auth.io.Clients & network
import { getPublicClient, getWalletClient, ensureChain, fuji } from "@avakit/core";
const publicClient = getPublicClient(fuji);
await ensureChain(provider, fuji); // add + switch the wallet's chain
const wallet = getWalletClient(fuji, provider);Deploy & data
import { deployContract, getBalance, readContract, fuji } from "@avakit/core";
const balance = await getBalance("0x…", fuji);
const { address, txHash, explorerUrl } = await deployContract({
artifact: { abi, bytecode },
chain: fuji,
provider,
account: "0x…",
});Chain data (Data API)
Indexed, read-only balances, NFT holdings, and transaction history from the AvaCloud Data API — no indexer to run. Each helper takes the address and the chain, which can be an AvaChain (like fuji) or a raw EVM chain id (43113 Fuji, 43114 C-Chain).
import { getNativeBalance, listNfts, fuji } from "@avakit/core";
const native = await getNativeBalance("0x…", fuji); // or: getNativeBalance("0x…", 43113)
const nfts = await listNfts("0x…", fuji);API surface
fuji,cChain,defineChain(from/chains)injectedAdapter,web3authAdapter(from/web3auth)getPublicClient,getWalletClient,toViemChain,ensureChaindeployContract,getBytecode,getBalance,getTransactionReceipt,readContractgetNativeBalance,listErc20Balances,listNfts,listTransactions(AvaCloud Data API, keyless)
