Skip to main content
These snippets assume you have publicClient, walletClient, a Newton API key, and a policy pack set up as shown in Getting Started.

Idempotent Attach or Deploy

createShield predicts the deterministic clone address and either attaches to an existing compatible clone or deploys a new one.
If a clone exists but the policy binding or params do not match your expectations, the SDK raises a typed configuration error instead of attaching silently.

Typed Morpho Call

Use the typed Morpho overlay for MetaMorpho manager actions.
Newton operators evaluate the configured policy before the Shield forwards the typed calldata.

Generic sendCall

Use sendCall for a manager action without a first-class vendor helper.
Prefer typed vendor modules when they exist. With sendCall, your app is responsible for matching the calldata, signature, target, and policy inputs.

Error Handling

Catch specific subclasses when retry behavior matters.
PolicyDeniedError is not retry-safe without changing the action or accepting the denial. Gateway and timeout failures are usually retry-safe with a fresh task.

Read-Only Inspection

Anyone can inspect a Shield clone without holding the curator key.
This is useful for dashboards, depositor diligence, and operations review.

Multiple Chains

Create one pack and one Shield client per chain. The SDK reads the chain from each walletClient; there is no global chain singleton.
If a chain is not in the SDK deployment registry, createShield throws UnsupportedChainError before sending a transaction.