View Source Hyperliquid.Api.Exchange.UserSigned (hyperliquid v0.3.1)
Shared EIP-712 signing for user-signed exchange actions.
User-signed actions (withdrawals, transfers, agent approvals) are signed over typed data rather than over the msgpack of the action, so field order does not affect the signature — but the EIP-712 domain does.
The domain's chainId and the action's signatureChainId must always agree:
the exchange rebuilds the domain from signatureChainId to recover the signer,
so if they drift the API recovers the wrong address and rejects the action.
Both come from Hyperliquid.Config.signature_chain_id/0, which is what keeps
them in step.
Summary
Functions
The EIP-712 domain used for every user-signed action.
"Mainnet" or "Testnet", the field that actually selects the network.
Sign a user-signed action's typed data.
The signatureChainId field to send in the action body.
Functions
@spec domain() :: map()
The EIP-712 domain used for every user-signed action.
@spec hyperliquid_chain() :: String.t()
"Mainnet" or "Testnet", the field that actually selects the network.
Sign a user-signed action's typed data.
Parameters
private_key: Private key for signingprimary_type: EIP-712 primary type, e.g."HyperliquidTransaction:UsdSend"types: List of%{name: ..., type: ...}field descriptors, in ordermessage: The message to sign
Returns
{:ok, %{r: ..., s: ..., v: ...}}{:error, {:signing_error, term()}}
@spec signature_chain_id() :: String.t()
The signatureChainId field to send in the action body.