Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SDK Overview

@koed_jang/apyx-sdk is a thin wrapper around viem. The whole package boils down to one factory function — createApyxClient — that returns an object with three contract modules and a few utility handles.

The shape of an ApyxClient

interface ApyxClient {
  // viem primitives, exposed for escape hatches
  chain: Chain;
  publicClient: PublicClient;
  walletClient?: WalletClient;          // present only when `account` was passed
  addresses: Readonly<ApyxAddresses>;   // EIP-55 normalized + Object.freeze'd

  // protocol modules
  apxUSD: ApxUSD;                       // ERC-20 + permit
  apyUSD: ApyUSD;                       // ERC-4626 vault wrapping apxUSD
  apyUSDRateView?: ApyUSDRateView;      // optional per chain
}

Module map

flowchart LR
  cfg[ApyxClientConfig\nchain + transport + ?account] --> factory(createApyxClient)
  factory --> client[ApyxClient]
  client --> apx[apxUSD\nERC-20]
  client --> apy[apyUSD\nERC-4626]
  client --> rv[apyUSDRateView\nyield view]
  client --> pub[publicClient]
  client --> wal[walletClient?]
  factory -. throws .-> e1{{UnsupportedChainError}}
  factory -. throws .-> e2{{InvalidAddressError}}
  apx -. throws on writes without account .-> e3{{WalletClientRequiredError}}
  apy -. throws on writes without account .-> e3

Public exports at a glance

Source of truth: src/index.ts.

ExportKindPage
createApyxClientfactory functionclient
ApyxClient, ApyxClientConfig, ApyxClientCoretypesclient
getAddresses, APYX_ADDRESSES, ApyxAddressesfunction + constant + typeaddresses
UnsupportedChainError, WalletClientRequiredError, InvalidAddressErrorerror classeserrors
ApxUSDAbi, ApyUSDAbi, ApyUSDRateViewAbityped as const ABI arraysabis

The apxUSD, apyUSD, and apyUSDRateView modules aren’t separately exported — they’re attached to the ApyxClient object you get back from the factory. Their per-method reference lives in apxUSD, apyUSD, and apyUSDRateView.

Read-only vs write-enabled

createApyxClient always returns a fully-functional read client. Pass account to additionally enable writes:

Pass account?walletClientreadswrites
noundefinedthrow WalletClientRequiredError
yesWalletClient

This split is intentional — every read-only consumer (UIs, indexers, dashboards) gets the smallest possible surface, and write paths fail fast at first call rather than silently constructing tx hashes against a phantom signer.

Where to next

  • createApyxClient — every config option, all three error throwing-points, the walletTransport escape hatch.
  • apxUSD, apyUSD, apyUSDRateView — per-method reference.
  • Errors — the three thrown error classes and how to recover.
  • AddressesAPYX_ADDRESSES registry, override semantics, EIP-55 normalization.
  • ABIs — raw ABI exports for use with viem directly.