Skip to main content
This page shows how to build the Private Sub-account flow on HyperEVM mainnet: derive a Sub-account, fund it from a shielded balance, trade from it, and bring the money back. Read Private Sub-accounts first for what the flow does and what it keeps private.

Where the code is

There is no published package for this flow yet. The pieces live in two places: Code on this page type-checks against the SDK, except where it uses the HyperEVM options noted in the text. It is illustrative. Fill in the values in square brackets from Network reference.

The flow

1. Derive a Sub-account

The key comes from your shielded signing key. You can recover every Sub-account from your wallet, so losing the browser loses nothing.
The mainnet and testnet contexts differ on purpose, so one wallet never has the same Sub-account address on both. In the app, the same derivation is called deriveBurner. Use a new index for every position. The app scans 24 indices when it looks for Sub-accounts it has used. Anyone who has your spending key can derive all your Sub-accounts, in the past and the future. Guard it as you guard the shielded account.

2. Fund it

Funding is one adaptor call from the shielded balance. The adaptor calls Circle’s USDC deposit contract with the Sub-account as the recipient, in the same transaction. USDC is the only supported token, and the adaptor enforces a minimum amount. See Status and limits.
Then sign and prove as usual and send the calldata to the relayer’s /fund endpoint. See Relayer API. The Sub-account is credited the full amount. The relayer fee is on top, taken from your notes. Wait for the relayer’s job to confirm. Do not retry blindly. A second call pays again. The app records each attempt before it pays, and a retry for the same Sub-account waits for the first one to land.

3. Confirm the credit

The deposit lands on Hyperliquid, not on HyperEVM. Check the Sub-account’s ledger with Hyperliquid’s info API, request type userNonFundingLedgerUpdates. Look for a send from the USDC deposit contract to the Sub-account for exactly the amount you funded. That match is exact, and it holds while positions move the balance. If the credit does not appear after a few minutes, it may still land. Do not fund the same Sub-account again until you have checked.

4. Trade

The Sub-account signs its own Hyperliquid actions. No Palliora contract and no Palliora server is involved. Use Hyperliquid’s API documentation for the signing rules, order formats and number formatting. The rules that matter for this flow:
  • Isolated margin. Call updateLeverage with isCross: false before the first order. The account is new, so you cannot assume a margin mode.
  • One position per Sub-account. Reuse links positions to each other and, in the end, to a return deposit. The app refuses to open a position on a Sub-account that has already traded.
  • Trading is gasless. Hyperliquid actions need no HYPE.
Size, direction, entry price, leverage and liquidation price are public on Hyperliquid and stay tied to the Sub-account’s address.

5. Move the money out

When the position is closed:
  1. Move free USDC from perp to spot with the usdClassTransfer action, with toPerp: false.
  2. Send the spot USDC to the token’s system address with the sendAsset action. For USDC (token index 0) that address is 0x2000000000000000000000000000000000000000. HyperCore moves it to the Sub-account’s HyperEVM address.
  3. Wait until the USDC shows in the Sub-account’s HyperEVM balance.
HyperCore charges about 1 USDC on an account’s first transfer out, and takes it from the USDC balance. A new Sub-account needs enough to cover that charge, the gas fee and the pool’s minimum deposit, or it cannot return the money. The app recommends a funding size that covers all three and does not block a smaller one.

6. Buy return gas

The Sub-account holds USDC on HyperEVM but no HYPE, and the return needs gas. Buying the gas from the user’s main wallet would link the two for good, so the GasStation sells a small amount of HYPE for a flat USDC fee. The Sub-account signs an EIP-3009 ReceiveWithAuthorization for the fee, and the relayer submits it. The Sub-account does not need gas to sign.
Read the station address and the price from the network, not from the relayer. The relayer can only submit what you signed. The signature binds the fee and the station, and the station sends the HYPE in the same transaction that takes the fee, so you pay nothing unless you receive the gas. Only buy gas when the Sub-account’s HYPE balance is below what an approve and a deposit need.

7. Return to your shielded balance

The Sub-account deposits its USDC to your main shielded address. Build the deposit with the user’s Core, because that makes the new note the user’s. Have the Sub-account submit it, because a deposit pulls tokens from the sender.
Do not register the Sub-account as a shielded account. A registration writes a public link from the Sub-account’s address to a shielded address, which is the link this flow exists to hide. The deposit proof does not bind the sender, so the Sub-account can submit a proof whose notes belong to the user. The proof shows that the recipient is a registered address, without showing which one. The pool’s minimum deposit applies to the return. See Status and limits.

Rules for builders

The Sub-account’s own address is public once it acts, and the funding call carries it as the adaptor payload. The rule is about everything else.

Testnet differences

The testnet flow does not use the funding adaptor. The relayer funds the Sub-account. The user withdraws USDC and HYPE together from the pool in a single transaction, with the relayer as paymaster, and the relayer forwards the money to the Sub-account on Hyperliquid. The private testnet SDK has two builders for it: The testnet derivation context is veilnyx/hl-burner/v1/. The mainnet context is veilnyx/hl-burner/m1/.

Next