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).
Use testnet: true while you’re getting started. The Hyperliquid testnet gives you a free environment to experiment without risking real funds.
1

Install the SDK

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

Create and initialize the adapter

Import createHIP4Adapter and call initialize() to warm up the event cache. Every other SDK method depends on this step completing first.
The adapter automatically connects to the correct Hyperliquid testnet endpoints for both REST and WebSocket traffic. Switch to { 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" or "multiOutcome", 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 - it never throws.
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 10 USDC notional floor at the given price. Passing markPx to placeOrder enables the SDK to validate 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.