Signing

Low-level utilities for signing Hyperliquid transactions. Most users don't need this - ExchangeClient handles signing automatically.

Use these utilities when:

  • Custom wallet integration - implement AbstractViemLocalAccount to use hardware wallets, MPC, or other signing systems

  • Signing unsupported actions - sign new action types that are not yet implemented in the SDK

Import

import {
  createL1ActionHash,
  PrivateKeySigner,
  signL1Action,
  signMultiSigAction,
  signUserSignedAction,
} from "@nktkas/hyperliquid/signing";

PrivateKeySigner

Lightweight signer that doesn't require viem or ethers.

import { PrivateKeySigner } from "@nktkas/hyperliquid/signing";

const signer = new PrivateKeySigner("0xabc123...");
console.log(signer.address); // "0x..."

Use with ExchangeClient:

signL1Action

Signs an L1 action - trading operations like orders, cancels, leverage updates, TWAP, vault operations, etc.

Parameters

wallet (required)

  • Type: AbstractWallet

Wallet to sign (viem, ethers, or PrivateKeySigner).

action (required)

  • Type: Record<string, unknown>

Action object. Key order matters for hash calculation.

nonce (required)

  • Type: number

Timestamp in milliseconds.

isTestnet (optional)

  • Type: boolean

  • Default: false

Use testnet instead of mainnet.

vaultAddress (optional)

  • Type: `0x${string}`

Vault addressarrow-up-right for trading on behalf of a vault.

expiresAfter (optional)

  • Type: number

Expiration timearrow-up-right of the action in milliseconds since epoch.

circle-exclamation

signUserSignedAction

Signs a user-signed action - transfers and administrative operations like withdraw, usdSend, spotSend, approveAgent, etc. Uses EIP-712 typed data with signatureChainId.

Parameters

wallet (required)

  • Type: AbstractWallet

Wallet to sign (viem, ethers, or PrivateKeySigner).

action (required)

  • Type: object

Action object with signatureChainId field.

types (required)

  • Type: object

EIP-712 types for the action. Import from @nktkas/hyperliquid/api/exchange (e.g., ApproveAgentTypes).

signMultiSigAction

Signs a multi-signature action. Requires signatures from multiple signers collected beforehand.

createL1ActionHash

Creates a hash of an L1 action without signing. Used internally by signL1Action as connectionId in EIP-712 structure. The hash depends on key order in the action object.

AbstractWallet

The SDK accepts any wallet that implements signTypedData. Supported out of the box:

Last updated