How to deposit and withdraw from Hyperliquid to any Relay chain
Relay supports depositing and withdrawing Hyperliquid (Hypercore) perpsUSDC from any supported chain. To try it today, use the Relay App. Relay also provides complete support for HyperEVM, which can be accessed using the standard quote flow with chainId=999. This document details how to integrate Hyperliquid deposits and withdrawals into your application.
Hyperliquid can be accessed using the standard Relay API flow. To get started, review the execution steps documentation. When you’re ready to execute swaps, refer to the Get Quote API endpoint.
These parameters are specific to Hyperliquid interactions. All other standard API parameters remain required. Note that protocolVersion: v2 is mandatory for withdrawals.
For currencies on HIP-3 DEXs (non-Spot and non-Perps), append the hex-encoded DEX name to the corresponding Spot currency address. For example, USDC on the xyz DEX is represented as 0x6d1e7cde53ba9467b783cb7c530ce05478797a, where 0x6d1e7cde53ba9467b783cb7c530ce054 is the Spot USDC address and 78797a is the hex representation of “xyz”.
Hyperliquid withdrawals use a two-step signature flow. The v2 implementation leverages the unique nonce associated with every Hyperliquid transfer to map deposits to request IDs. This requires two signatures:
Authorize: Sign a nonce-mapping message that associates a specific nonce with a request ID
Deposit: Sign and submit the Hyperliquid transfer transaction using the same nonce
The deposit transaction must use the exact same nonce from the authorization
signature. If the nonces don’t match, Relay cannot associate the transfer with
the request ID.
Use the Hyperliquid info API to query balances. Pass clearinghouseState as the type parameter, then read the withdrawable property, which returns a USD value in human-readable format.
The first step (id: authorize) requires signing an EIP-712 message that maps the nonce to the request ID. This signature can be executed on any EVM chain.
When signing on a different chain than the default, update both
item.data.sign.domain.chainId and item.data.post.body.signatureChainId to
match the chain ID where the user signs the message.
After the message is signed the second action is to submit the post body to the endpoint provided in the post data. You’ll also need to provide the signature that was generated from the sign data as a query parameter.
The second step (id: deposit) requires signing and submitting the actual Hyperliquid transfer. The API response includes eip712Types and eip712PrimaryType to simplify constructing the signature data.Example deposit step response:
To sign the deposit step, you need to convert it into EIP-712 signature data. Extract the necessary fields from the step response and construct the signature object: