Skip to main content
@hedginvault/sdk is a TypeScript client for the Hedgin manager API. It turns the API’s build, sign, send, and confirm sequence into one call, and it refuses to sign any server-built transaction that could move funds out of the manager wallet. The API still builds every transaction. The SDK calls the API, inspects what comes back, signs locally, sends, and tracks the result. The manager key never leaves your process.
The SDK targets the manager API described in the API reference. Use it when you run a bot or script that manages a vault. To click through the same actions, use the Telegram bot.

Install

The package is not on npm. sdk/package.json is marked private, so for now you consume a packed tarball built from the sdk/ repository:
@solana/web3.js (^1.98.4) is a peer dependency. Install it yourself so the SDK and your code share one copy of Keypair, PublicKey, and VersionedTransaction. The SDK builds to CommonJS and uses the global fetch and AbortSignal.timeout, so it needs Node 18 or later. It has two runtime dependencies, zod and bs58.

Get an API key

A manager key looks like hv1_<id>_<secret>. A Hedgin admin issues it from the admin dashboard. Each key is bound to one manager wallet and carries a list of allowed actions, called scopes. See Key scopes for what each SDK call needs. Keep the key and the wallet keypair in your secret store. The examples read the API key from HEDGE_API_KEY and the keypair from a Solana CLI JSON file.

Create a client and run an action

createHedgeClient returns a HedgeClient. keypairSigner wraps a Keypair as a TransactionSigner, and keypairFromFile reads a Solana CLI keypair file.
execute builds the transaction, inspects it, signs it, sends it, and polls until it lands or fails. The result is an Outcome.

Client options

createHedgeClient takes a HedgeClientOptions object.
Reads time out after 10 seconds and builders after 30 seconds. A builder simulates on chain and can call Jupiter, so it gets more time.

Read the outcome

execute and onboardPhoenix return an Outcome. Check outcome.kind before you act on anything else. Every kind carries signatures, the signatures of everything sent so far. See Execute and safety for how execute reaches each outcome and why it never rebuilds after an ambiguous send.

Amounts are strings

Token amounts cross JSON as base-unit integer strings, such as "1000000" for 1 USDC. The SDK types them as BaseUnitString and never uses a JavaScript number for an amount. Convert display values with parseUnits and formatUnits. See Units and helpers.

Where to go next

Reads

Every read method, with its route and return type.

Actions

Every action that execute runs, and the key scope each needs.

Execute and safety

The signing policy, batches, continuations, and unknown outcomes.

API checker

Probe a live API for drift from the SDK’s schemas.