Skip to main content
This page walks through examples/web-trading. Read the overview first for who signs what. Markets load as in Showcase markets code, and market below is one HIP4Market from loadEvents.
1

Install

2

Connect the wallet

src/trading.ts
If hip4.client.fetchUserRole(address) returns { role: "missing" }, the wallet has no Hyperliquid account yet. The user deposits USDC on Hyperliquid first.
3

Enable trading

src/trading.ts
4

Move USDC to spot

Outcome trades use the spot balance. Check when the wallet connects, and offer the move if USDC sits in perps.
src/trading.ts
5

Show the order book

Pass side 0 or 1. Asks come lowest first and bids highest first, as { price: "0.61", size: "120.0" }.
6

Place and cancel orders

To charge your builder fee, add builderAddress and builderFee to each order, or pass them to createHIP4Adapter.
7

Show the account

The example app puts all of this on one page. See src/main.ts.

Next steps

  • Trading, for every option of placeOrder, placeOrders and cancelOrder
  • Authentication, for how the session key signs