Skip to main content
Agent wallets (also called API wallets) are permissioned signers that hold no funds but can execute Hyperliquid actions on behalf of a master account. With Dynamic’s Node SDK you manage the master wallet server-side via MPC, while agent wallets are lightweight ephemeral keypairs generated with viem. This pattern lets you:
  • Keep funds locked in a secure MPC master account
  • Rotate agent keys without disrupting active trading
  • Give each bot or strategy its own isolated nonce space
  • Preserve consolidated fee tiers and account-level PnL under one master account
If you are building a browser or React Native app where a human user controls the master wallet, see the Hyperliquid SDK integration recipe instead. This recipe is for server-side / agentic use cases where the master wallet is managed programmatically.

How it works

Dynamic’s Node SDK creates one MPC wallet per chain — ideal for the master account that secures your funds. Agent wallets are generated with generatePrivateKey from viem and stored in your secrets manager.
The master wallet must be funded on Hyperliquid before approveAgent can be called. Fund it via the Hyperliquid app (mainnet) or testnet app first. The testnet faucet requires a prior mainnet deposit — the simplest path is to use a pre-funded account or test on mainnet with a small amount.

Installation

Environment setup

Step 1: Initialize the Dynamic client

Step 2: Create or retrieve the master wallet

For this pattern it makes sense to use a single master wallet per chain — one account that holds funds and signs agent approvals. Create it once, persist the address, and reuse it on every subsequent run.
Never log or persist the derived private key. Use getMasterViemAccount to get an in-memory signer only, and discard the key immediately after use.

Step 3: Create or load the agent wallet

Agent keys should be stored in a dedicated secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.) and looked up by address or bot ID at runtime. The key itself never needs to touch your application database.

Step 4: Approve the agent on Hyperliquid

The approveAgent transaction is signed by the master wallet and recorded on-chain. It only needs to be called once per agent address — checking extraAgents first keeps the function idempotent.

Setting an expiry on the agent

Encode an expiry timestamp directly in the agent name using Hyperliquid’s valid_until convention. Hyperliquid enforces this server-side.

Step 5: Trade with the agent wallet

Once approved, the agent wallet signs all orders directly — the master wallet is not involved in individual trades.

Listing active agents

Putting it all together

Key concepts

Last modified on April 14, 2026