Setup and configuration
Create an SDK instance from a network profile and viem clients.
Everything in the SDK hangs off one AnvilSDK
instance. Build it once from a viem public client and a profile, then share it: sdk.loc,
sdk.vault, sdk.pricing, and sdk.tokens hold every read and every workflow the rest of this
reference describes.
A public client is enough to read state, validate input, and build workflows. Add a wallet client
when your app needs to execute one.
AnvilDependencies lists everything
the constructor accepts, and
testnetProfile and
mainnetProfile carry each network’s
contract addresses and subgraph endpoint.
LOCConfig holds terms your product fixes,
such as a required Beneficiary or expiration, which the workflow builders and the React components
both enforce.
Environments and profiles explains which profile to use, and Where data comes from shows which reads go to the subgraph and which go to the chain.
A read-only instance against 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.
Profiles
testnetProfile— The testnet profile, derived from the deployment record.mainnetProfile— The mainnet profile, derived from the deployment record.