Technical overview
L1 actions use a phantom agent construction - a temporary signing identity created from your action’s hash. This provides privacy by hashing the actual data before signing.The Hyperliquid Python SDK v0.18.0+ handles phantom agent construction internally. You don’t need to implement this complexity yourself.
Key characteristics
Property | Value |
---|---|
Chain ID | 1337 (NOT Arbitrum’s 42161) |
Domain name | ”Exchange” |
Version | ”1” |
Serialization | Msgpack binary format |
Agent type | Phantom agent from action hash |
Source | ”a” for mainnet, “b” for testnet |
What is a phantom agent?
A phantom agent is a cryptographic construct that provides privacy for trading operations:1
Serialize action
Action is serialized using msgpack binary format
2
Append metadata
Nonce and vault address (if applicable) are appended
3
Hash the data
Complete data is hashed with keccak256
4
Create agent object
Temporary “agent” object created with hash as connectionId
5
Sign via EIP-712
This phantom agent is signed using EIP-712 typed data
Supported L1 actions
All L1 actions use the same signing methodsign_l1_action()
- only the action payload changes:
Trading actions
order
— Place new orderscancel
— Cancel orders by order IDcancelByCloid
— Cancel orders by client order IDmodify
— Modify existing ordersbatchModify
— Modify multiple orders
Position management
updateLeverage
— Adjust leverage for positionsupdateIsolatedMargin
— Manage isolated margin
Transfers
vaultTransfer
— Transfer between vault accountssubAccountTransfer
— Transfer between sub-accounts
Utility
scheduleCancel
— Schedule order cancellationnoop
— No operation (for testing)
Complete implementation example
Action payload examples
Place order
Cancel order
Modify order
Update leverage
Technical implementation details
Phantom agent construction
EIP-712 domain
Type definition
TypeScript implementation
Configuration file
Create aconfig.json
file:
Common errors and solutions
Wrong chain ID
Never use Arbitrum’s chain ID (42161) for L1 actions. Always use chain ID 1337.
Invalid action format
Ensure action payloads match the expected structure:Nonce issues
Always use current timestamp in milliseconds:Testing your implementation
1
Start with noop
Test with a
noop
action first - it validates signing without any side effects2
Use testnet
Test on testnet before mainnet:
constants.TESTNET_API_URL
3
Verify signatures
Check that signatures have proper r, s, v components
4
Monitor responses
Successful actions return
{"status": "ok"}
or order detailsBest practices
DO
- Use the official SDK when possible
- Keep private keys secure (use environment variables)
- Test thoroughly on testnet first
- Handle errors gracefully
- Use proper nonce management
DON’T
- Hardcode private keys in code
- Mix up chain IDs (1337 vs 0x66eee)
- Reuse nonces across requests
- Skip error handling
- Use outdated SDK versions
Summary
L1 actions use phantom agent construction for privacy - the actual data is hashed before signing. The SDK’ssign_l1_action
handles all complexity internally, making it easy to implement trading operations securely.
Related resources
- Hyperliquid signing overview — Quick reference for both signing types
- User-signed actions guide — For administrative operations
- Exchange API reference — Complete API documentation