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 - Module map
- Public exports at a glance
- Read-only vs write-enabled
- Where to next
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.
| Export | Kind | Page |
|---|---|---|
createApyxClient | factory function | client |
ApyxClient, ApyxClientConfig, ApyxClientCore | types | client |
getAddresses, APYX_ADDRESSES, ApyxAddresses | function + constant + type | addresses |
UnsupportedChainError, WalletClientRequiredError, InvalidAddressError | error classes | errors |
ApxUSDAbi, ApyUSDAbi, ApyUSDRateViewAbi | typed as const ABI arrays | abis |
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? | walletClient | reads | writes |
|---|---|---|---|
| no | undefined | ✅ | throw WalletClientRequiredError |
| yes | WalletClient | ✅ | ✅ |
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
walletTransportescape hatch. - apxUSD, apyUSD, apyUSDRateView — per-method reference.
- Errors — the three thrown error classes and how to recover.
- Addresses —
APYX_ADDRESSESregistry, override semantics, EIP-55 normalization. - ABIs — raw ABI exports for use with viem directly.