Skip to content
LogoLogo

Signing reference

Exact signing formats for custom clients. The SDK handles these automatically.

Reads, native trades and withdrawals use separate signing domains. Their proofs are not interchangeable.

Authorization by operation

OperationSignerProof
POST /infoAccount owner or an approved reader; trading permission includes reads.PrivateRequest signature in the three HTTP headers below.
/ws subscribe or unsubscribeAccount owner or an approved reader for subscription.user.PrivateRequest signature in the message's auth object.
POST /exchange or /ws action postAccount owner or an approved trading agent.Native Hyperliquid {action, nonce, signature, ...} envelope.
requestWithdrawal on POST /exchangeAccount owner only.EIP-712 WithdrawalIntent signature.
/ws application pingNo account permission is granted.No request signature.

Check the recovered signer's permission for the requested account. Only owners grant access or withdraw.

Deployment context

Configure the settlement chainId and brokerage vault from the deployment configuration. The values must match the financial identity obtained over the independently verified enclave connection. HyperEVM mainnet uses 999; testnet uses 998. The deployment's vault address is required; the zero address is not a deployment substitute.

Use this exact EIP-712 domain for private reads and subscription controls:

Domain fieldValue
nameHyperjutsu
version1
chainIdDeployment's settlement chain ID.
verifyingContractDeployment's brokerage vault address.

Use these four domain fields, without salt. Get the host and context from trusted configuration, not unverified identity JSON.

PrivateRequest signed type

PrivateRequest fields, in order:

FieldEIP-712 typeValue
methodstringPOST for /info; WS for subscription controls. Case-sensitive.
pathstring/info or /ws. No origin, query string or trailing slash.
payloadHashbytes32Keccak-256 of the canonical request JSON, encoded as UTF-8.
timestampuint64Request creation time in Unix milliseconds.
noncebytes32Fresh cryptographically random 32-byte value for this request.

Type string:

PrivateRequest(string method,string path,bytes32 payloadHash,uint64 timestamp,bytes32 nonce)

Sign the EIP-712 digest using signTypedData / eth_signTypedData_v4. Do not add an Ethereum personal-message prefix or sign a text rendering of the digest. The signature is a 0x-prefixed, 65-byte secp256k1 r || s || v value, with canonical low s and v equal to 27 or 28. Compact 64-byte signatures and contract-wallet EIP-1271 signatures are outside this signing profile.

Canonical payload

Use the JSON Canonicalization Scheme, RFC 8785 before hashing:

  1. For HTTP, canonicalize the complete native /info request object.
  2. For WebSocket controls, canonicalize the complete {method, subscription} object with the top-level auth field removed.
  3. Encode the canonical string as UTF-8 and compute Keccak-256. This is Ethereum Keccak-256, not NIST SHA3-256.

JCS ignores wire whitespace and object-key order. Preserve array order, strings, address case and omitted fields after signing.

The signed JSON must contain unique object keys, valid Unicode strings and safe integer numbers with absolute value at most 9,007,199,254,740,991. Fractions, negative zero, non-finite numbers and undefined are rejected by the example helper. Query schemas further constrain numeric values to their documented unsigned ranges. For an order ID outside the safe-integer range, use its string CLOID for order-status lookup; do not round the ID or invent a decimal-string OID encoding. Monetary quantities remain decimal strings.

Freshness and replay

The server accepts a timestamp no more than 30 seconds in the past or 5 seconds in the future relative to its clock. Generate a fresh nonce for every request, including retries. A nonce is single-use per recovered signer and signing domain. Acceptance consumes it after signature, request-shape and permission validation; the same nonce cannot authorize another accepted request while its timestamp remains valid.

Read nonces are separate from trading nonces. Retry reads with fresh proofs; reconcile uncertain orders before replacing them.

The timestamp controls request admission, not subscription lifetime. Check current permission before later deliveries. New sockets need fresh signed subscriptions.

HTTP proof headers

Keep the native /info JSON body unchanged and add all three headers:

HeaderEncoding
X-Hyperjutsu-TimestampCanonical base-10 Unix millisecond timestamp, without a sign or leading zeroes.
X-Hyperjutsu-Nonce0x followed by 64 hexadecimal characters.
X-Hyperjutsu-Signature0x followed by 130 hexadecimal characters.

Set Content-Type: application/json. Header names are case-insensitive. Do not put proofs or reusable credentials in URLs, query strings or cookies.

The native query body remains:

{
  "type": "openOrders",
  "user": "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"
}

Complete HTTP fixture, using chain 998, the example vault 0x3333333333333333333333333333333333333333 and the published test owner. Its frozen timestamp makes it unsuitable for a live request:

POST /info HTTP/1.1
Host: <configured-api-host>
Content-Type: application/json
X-Hyperjutsu-Timestamp: 1796250000000
X-Hyperjutsu-Nonce: 0x0101010101010101010101010101010101010101010101010101010101010101
X-Hyperjutsu-Signature: 0x6b39d528cc6f043b7068fd1e66dbddf02ef55865b14a955cc112072685b4f43a408bb707500a309e6e3dc360f003479569e3b69980f8c9461bbbbfb808fb78cd1c
 
{"type":"openOrders","user":"0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"}

WebSocket proof object

Add auth beside method and subscription:

FieldTypeMeaning
auth.timestampIntegerSame millisecond timestamp used in the signed message.
auth.nonceHex stringFresh 32-byte nonce.
auth.signatureHex stringCanonical 65-byte signature.

Both subscribe and unsubscribe use method: "WS" and path: "/ws" in the EIP-712 message. Their native method values remain inside the signed payload, so a subscribe proof cannot authorize unsubscribe. Do not include auth itself in payloadHash.

Acknowledgements echo the subscription only. Server updates need no customer signature. Action posts use native signatures without PrivateRequest.

TypeScript signing example

Install the maintained signing and canonicalization packages:

npm install viem canonicalize

Download the complete signing helper. Its input is a configured Viem wallet, the signing address, the verified deployment context and the native request body. It validates the JSON profile, uses the system CSPRNG for nonces and signs this exact type:

import { keccak256, stringToHex } from 'viem'
import {
  canonicalRequest,
  privateDomain,
  privateRequestTypes,
} from './private-request'
 
const signature = await wallet.signTypedData({
  account: signer,
  domain: privateDomain({ chainId, vault }),
  types: privateRequestTypes,
  primaryType: 'PrivateRequest',
  message: {
    method: 'POST',
    path: '/info',
    payloadHash: keccak256(stringToHex(canonicalRequest(body))),
    timestamp: BigInt(timestamp),
    nonce,
  },
})

Build an HTTP request using verified chainId, vault and wallet configuration:

import {
  canonicalRequest,
  privateHeaders,
  signPrivateRequest,
} from './private-request'
 
const body = { type: 'openOrders', user: owner }
const auth = await signPrivateRequest(
  wallet, signer, { chainId, vault }, 'POST', '/info', body,
)
const request = {
  method: 'POST',
  headers: privateHeaders(auth),
  body: canonicalRequest(body),
}

For a native WebSocket subscription:

const body = {
  method: 'subscribe',
  subscription: { type: 'openOrders', user: owner },
}
const auth = await signPrivateRequest(
  wallet, signer, { chainId, vault }, 'WS', '/ws', body,
)
const message = JSON.stringify({ ...body, auth })

Send these requests through the independently verified enclave connection. For browser clients, construct the proof first and carry it inside the encrypted transport: HTTP plaintext uses {authorization: auth, body}, while WebSocket plaintext uses {body: {...body, auth}}. Do not expose the proof in the outer encrypted request's headers or WebSocket URL. Request signing provides authorization; the attested transport provides confidentiality.

Published test vectors

The private-request vectors contain the canonical JSON, payload hash, EIP-712 digest, signature, recovered signer and complete request for one /info query and each supported subscription control shape. They use the public development key 0x0000000000000000000000000000000000000000000000000000000000000001, a fictitious vault and a frozen timestamp. Never fund the test key. The signatures verify cryptographically but their frozen timestamps are stale; generate a fresh timestamp and nonce when sending a request.

Native trading signatures

Orders, cancellations and leverage actions use the same signed native envelope over HTTP and WebSocket. The WebSocket wrapper does not change the action signature. The Hyperjutsu SDK builds these signatures internally when you call an exchange method.

The native hash is Keccak-256 of this byte sequence:

MessagePack(action)
|| uint64_be(nonce)
|| vault_marker
|| optional_expiry

For this profile, vaultAddress is omitted or null, so vault_marker is one zero byte. If expiresAfter is non-null, optional_expiry is one zero byte followed by uint64_be(expiresAfter). Omitted or null means no expiry bytes. Preserve action-object insertion order and integer types when constructing the MessagePack representation. Do not sort the action using JCS; that canonicalization belongs only to PrivateRequest.

The EIP-712 domain is Exchange, version 1, chain ID 1337, zero verifying contract. Its primary type is Agent(string source,bytes32 connectionId), where connectionId is the native hash and source is a for mainnet or b for testnet. The trading signature is the native {r, s, v} object, with nonzero valid scalars, low s and recovery byte 27 or 28.

With a configured SDK client, submit the action directly:

const result = await exchange.order({
  orders: [{
    a: 0,
    b: true,
    p: '100000',
    s: '0.001',
    r: false,
    t: { limit: { tif: 'Gtc' } },
  }],
  grouping: 'na',
})

The SDK generates the envelope for HTTP or WebSocket using its configured environment.

The default trading freshness profile permits 60 seconds of age and 5 seconds of future skew; an explicit, non-null expiresAfter must be greater than the server time and greater than or equal to nonce. Use unique millisecond nonces per signing key, across both transports. The highest 100 accepted nonces form an out-of-order window: duplicates and values below its retained floor are rejected. HTTP and WebSocket do not have separate nonce windows.

Native Hyperliquid signatures do not bind the API host or a Hyperjutsu-specific deployment. Use a dedicated Hyperjutsu trading agent and do not reuse it for another brokerage or your independent native account. A private-read proof uses a different domain and does not replace this trading signature.

Withdrawal signing

requestWithdrawal uses the brokerage vault's EIP-712 domain:

Domain fieldValue
nameBrokerage Settlement
version1
chainIdDeployment's settlement chain ID.
verifyingContractDeployment's brokerage vault address.

WithdrawalIntent, in field order:

WithdrawalIntent(bytes32 withdrawalId,address owner,address recipient,address asset,uint64 amount,uint64 maxFee,uint8 destination,bytes32 nonce,uint64 deadline)

All fields come from action.intent on the withdrawal call. amount and maxFee use six-decimal USDC atomic units. deadline is in Unix seconds, unlike request and trading timestamps. The normal HyperEVM payout destination is 0. Signer recovery must equal owner; read and trading agents cannot authorize a payout.

Use the same Viem signTypedData API with this domain, primaryType: "WithdrawalIntent" and the exact field list above. Carry the resulting canonical 65-byte signature as the withdrawal request's top-level signature string. Withdrawal IDs and nonces are separate from private-read nonces and native trading nonces.

Failures and revocation

For HTTP, a missing, malformed, expired, replayed or unauthorized private proof returns 401 with {"code":401,"msg":"private_access_denied"}. Unsupported query shapes return 422 with {"code":422,"msg":"unsupported_or_invalid_request"}. Capacity and service availability failures use the documented 429 or 503 response. Private responses are not cacheable. Invalid private subscription requests can close the WebSocket rather than return an HTTP status after upgrade.

A signature is checked against current permission. Expiry or revocation blocks subsequent requests and queued subscription deliveries. Repeating an authorized subscription with a fresh proof acknowledges the existing subscription; it does not add another stream or force a new snapshot. Proof validation never grants withdrawal or agent-management authority.