- 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
generatePrivateKey from viem and stored in your secrets manager.
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.
Step 3: Create or load the agent wallet
Step 4: Approve the agent on Hyperliquid
TheapproveAgent 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’svalid_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
Related
- Hyperliquid SDK integration — browser and React Native integration with user-controlled wallets
- Agents Overview — wallet patterns for AI agents (server wallets and delegated access)
- Hyperliquid API documentation
- Hyperliquid SDK repository