Skip to main content
This guide walks you through the full integration path, meaning that by the end, you’ll have a working adapter, a list of available markets, and order submissions functional and verifiable (via the Hyperliquid exchange).
The SDK targets the Hyperliquid testnet by default, a free environment to experiment without risking real funds. Pass testnet: false to target mainnet.
1

Install the SDK

Add @outcome.xyz/hip4 to your project:
2

Create and initialize the adapter

Import createHIP4Adapter and call initialize(). It loads the market side names that prices and positions use.
The adapter connects to the Hyperliquid testnet endpoints for both REST and WebSocket traffic. testnet: true is also the default when you omit the option. Pass { testnet: false } when you’re ready for mainnet.
3

Fetch markets

Call fetchMarkets() to retrieve live prediction markets. The response is an array of typed market objects - each one carries pre-computed side identifiers, expiry dates, and outcome metadata.
defaultBinary markets are recurring price binary markets (e.g. “Will BTC be above $69,070 at expiry?”). You can also filter by "labelledBinary", "multiOutcome", or "priceBucket", or omit the type filter to get all markets.
4

Set up authentication

Trading requires an approved ephemeral agent key. The agent key signs orders on your behalf without exposing your main wallet’s private key. The approval flow is a one-time operation per agent.
After initAuth() completes, the adapter signs all subsequent orders automatically using the agent key.
5

Place a limit order

With auth initialized, call hip4.trading.placeOrder() to submit a limit order. The method returns a result object instead of throwing on rejections.
Placing orders on mainnet (testnet: false) uses real funds. Make sure your account has sufficient USDC balance before submitting.
getMinShares(markPx) computes the minimum number of shares required to meet the $1 notional floor (MIN_NOTIONAL) at the given price. Passing markPx to placeOrder makes the SDK check this before signing and submitting.

Next steps

  • Read the core concepts to understand market types, coin naming, and the two signing flows.
  • See the trading guide for market orders, cancellations, and builder fee configuration.
  • Explore the real-time data guide to subscribe to live order books and price streams.