Setup and configuration
Create an SDK instance with a generated environment profile and viem clients.
Everything in the SDK hangs off one AnvilSDK instance. You
construct it with viem clients and, for every environment, one generated profile; from there
sdk.loc, sdk.vault, and sdk.pricing are the namespaces the rest of this reference documents.
Build it once and share it.
A generated profile plus a public client are enough to read state, validate parameters, and build
workflows; a wallet client is needed only to execute one.
AnvilDependencies is the full shape of what you
may pass: the generated profile, the two clients, an optional subgraph URL override, and an oracle
staleness buffer. Each profile binds every named protocol address to the ABI deployed there;
profile-free construction and address-only overrides are rejected.
anvilProfiles carries a ready-made profile for each
supported public environment. LOCConfig is a separate
concern: per-instance policy, such as a beneficiary allowlist, that the workflow builders and the
React forms both enforce.
Which reads come from the subgraph and which go straight to the chain is set out in the Where data comes from.
A read-only instance against public testnet:
// No walletClient: queries, validation, and workflow building all work;// only executing a workflow needs a signer.const sdk = new AnvilSDK({ publicClient: createPublicClient({ chain: sepolia, transport: http('https://your-rpc-url'), }), profile: testnetProfile,});
// A direct contract read; no wallet and no subgraph involved.const loc = await sdk.loc.getOutstandingLetterOfCredit({ id: 1n });console.log(loc);Primary APIs
The SDK instance
AnvilSDK— The entry point for the Anvil SDK.
Configuration
AnvilDependencies— The dependencies anAnvilSDKinstance needs to operate: your viem clients plus a generated environment profile and optional subgraph,…LOCConfig— Per-instance policy for LOC creation and redemption, passed aslocConfigon AnvilDependencies.
Composing without an instance
SDKContext— The minimum an SDK function needs to run: the dependencies it was configured with and a logger.
Supporting types and functions in this group are not listed here; each has its own page, listed with the group in the sidebar.