HIP-4 uses a two-layer authentication model. The outer layer is your user’s wallet - an EOA (externally owned account) that holds funds and controls the account on-chain. The inner layer is an ephemeral agent key: a temporary keypair your application generates that the user authorizes once to sign orders on their behalf. After that one-time approval, all order placement and cancellation happens silently through the agent key without any wallet prompts. A separate signing path - standard EIP-712 with the user’s actual wallet - still handles fund transfers, withdrawals, and sends, since those operations move real money and should always require explicit user approval.Documentation Index
Fetch the complete documentation index at: https://docs.outcome.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Why an agent key?
Every order on Hyperliquid’s L1 requires a signature. Without an agent key, your app would need to prompt the user’s wallet for each order - which is impractical for active trading. The agent key solves this: the user signs a single on-chain approval that says “this key may act on my behalf,” and from then on your app can sign orders silently using the agent’s private key, which you hold in memory.Auth setup
Generate an ephemeral agent private key
Use viem’s
generatePrivateKey to create a fresh keypair. This key exists only in memory for the duration of the session.Build the typed data for agent approval
getAgentApprovalTypedData returns the EIP-712 typed data the user needs to sign. Pass the agent’s address, a human-readable name for your app, the current timestamp as a nonce, and a boolean indicating whether you’re targeting mainnet.User signs the typed data with their wallet
Present the typed data to your user’s wallet. This is the only wallet prompt in the auth flow.
Submit the agent approval on-chain
submitAgentApproval sends the signed approval to the Hyperliquid exchange. The same nonce you used to build the typed data must be passed here.Signing flows
The SDK uses two distinct signing paths depending on the operation.L1 agent signing
Used for: order placement, order cancellation, USDH spot buy/sell. The agent key signs silently without any user interaction. The SDK serializes the action using MessagePack, hashes it with keccak-256, then produces an EIP-712 signature with theAgent type on the Hyperliquid phantom domain (chainId: 1337). This happens automatically whenever you call hip4.trading.placeOrder, hip4.trading.cancelOrder, or hip4.wallet.buyUsdh / hip4.wallet.sellUsdh.
User-signed EIP-712
Used for: fund transfers (transferToSpot, transferToPerps), withdrawals, USD sends.
These operations require the user’s actual wallet because they move funds. Set the wallet signer separately using hip4.wallet.setSigner, and the adapter will prompt the user’s wallet when needed.
The HIP4Signer interface
Any object that implementsHIP4Signer can be passed to hip4.auth.initAuth. The interface requires two methods:
HIP4Signer is compatible with viem’s PrivateKeyAccount (returned by privateKeyToAccount) and with ethers Wallet objects. The SDK normalizes the return value, so either an HLSignature object ({ r, s, v }) or a hex string is accepted.
Checking auth status
Callhip4.auth.getAuthStatus() at any time to inspect the current state.
Clearing auth
To reset the adapter to its unauthenticated state - for example, when the user disconnects their wallet - callclearAuth.