chainId=999
. This document details how to deposit and withdraw from Hyperliquid within your app.
API Access
Hyperliquid can be accessed using the standard Relay API flow, with the following properties. To get started, check out the execution steps of our API. Then when you’re ready to swap, head over to the Get Quote API endpoint.Hyperliquid Specific API Parameters
Action | Parameter | Input | Description |
---|---|---|---|
Deposit to Hyperliquid | toChainId | 1337 | Hyperliquid Chain Id |
recipient | Hyperliquid Address | ||
Withdrawals from Hyperliquid | useDepositAddress*** | true | |
fromChainId | 1337 | Hyperliquid Chain Id |
*** for withdrawals useDepositAddress:true is a required param do to the current structure of hypercore.
Currency Addresses
- Perps USDC is treated in a custom way with its address being
0x00000000000000000000000000000000
- For any other Spot currency the address is the tokenId value returned by the Hyperliquid RPC
- The address of non-Spot and non-Perps currencies (eg. currencies on HIP-3 DEXs) is determined by appending the hex-encoded DEX name at the end of the corresponding Spot currency address used by the DEX. For example,
USDC
on thexyz
DEX is represented as0x6d1e7cde53ba9467b783cb7c530ce05478797a
, where0x6d1e7cde53ba9467b783cb7c530ce054
is the address of Spot USDC and78797a
is the hex representation of “xyz”.
Interacting with Hyperliquid to Initiate Withdrawals
In order to facilitate withdrawals from hyperliquid in your application, you need to query users balances, and submit hyperliquid transactions.Getting Hyperliquid Balances
You can use the Hyperliquid info API to get balances. Make sure to pass inclearinghouseState
as the type
. Then you can read the withdrawable
property which should be a USD value in human readable format.
Submitting Hyperliquid Tx
Once you verify that your address has a usdc perps balance you must sign a message proving ownership over the account and verifying an amount of USDC perps that can be withdrawn. The Relay SDK already handles this for you but here’s a step by step guide on how to do this yourself.- You’ll need to take the quote (which returns a transaction step) and convert this into signature data:
domain
- static except for thechainId
.chainId
is the active chain id in the connected wallet. This is the chain id that will sign the message. Next up is the types. These are also static and can be hardcoded.primaryType
should match the name of the first type.value
dynamic execution datasignatureChainId
is the hex representation of the aforementioned active chain id.
“ok”
.
To see how an example you can have a look at our publicly available SDK.