Authentication
Open and enable a wallet with one owner signature, sign in over WebSocket or HTTP, and sign every write as a raw envelope for one Atlas chain ID, with a gapless or increasing nonce.
On this page
- Keys and authority
- Who signs what
- Open an account and enable trading
- Enable trading
- The statements
- Signed messages
- Signing domains
- Add the network to a wallet
- Sign in to a WebSocket
- The signed message
- auth.challenge
- auth.signIn
- HTTP sessions
- auth.login
- auth.refresh
- auth.logout
- auth.createHandoff
- auth.redeemHandoff
- Connect to the trading gateway
- Sign a transaction
- The envelope
- Action encoding
- Advanced orders
- The signature
- Typed (EIP-712) signing
- Opaque signing
- Transaction ID
- Nonce
- Gapless
- Increasing
- A refused request
- Server time
- Errors
ATLAS has no passwords. Every authority check is a secp256k1 signature that the server recovers a key from. There are five things you sign, for five different jobs.
| You sign | To | Where | Signed by |
|---|---|---|---|
RetailWsHandshake (EIP-712) | Open the optional trading WebSocket for an account | First frame on /seq/ws | The owner key or a key bound to the account. It grants no authority by itself |
SignIn (EIP-712) | Bind a WebSocket connection to an account | auth.signIn on /account/ws | The owner key |
Login (EIP-712) | Open an HTTP session for private reads | auth.login on POST /account/rpc | The owner key, or a key bound to the account |
| A signed transaction (a raw envelope) | Trade, manage keys and accounts, move funds, and send TP/SL and TWAP requests | atlas.sendRawTransaction on POST /seq/tx or /seq/ws | The owner key or a bound instruction key, as each command allows |
| A signed message (raw bytes) | Accept a new terms version | atlas.sendRawMessage on POST /seq/tx or /seq/ws | The owner key |
There is no registration call. A deposit waits at your address, and your first owner signature opens the wallet: see Open an account and enable trading. Market data and most account reads need no authentication at all.
- Curve
- secp256k1, recoverable signatures, low-
sonly - Signature format
- 65 bytes,
r ‖ s ‖ v, withvin {0, 1}. Transactions and messages add one scheme byte - Account identity
- A 20-byte address, derived from the key like an Ethereum address
- What a transaction signs
- The Atlas chain ID (33003), the
authorityaccount, thesigner, the nonce and the command - Transaction domain
EIP712Domain(string name,string version,uint256 chainId,bytes32 salt), nameatlas, version"1", saltkeccak256("atlas"),chainIdthe chain your wallet signs at- Write transport
atlas.sendRawTransactionwith"params": ["0x…"], overPOST /seq/txor/seq/ws- Replay protection
- Single-use challenge (sign-in and login); a per-key-slot nonce, gapless or increasing (transactions)
Keys and authority
Your wallet is your master identity, and it is named by an address: the last 20 bytes of keccak256(x ‖ y) of your key's public point, exactly as for an Ethereum address. The wallet's first account, Main, has that same address. Each sub-account you create has an address of its own. Two kinds of key act on a wallet's accounts. A wallet's owner can also be a signing policy, several keys of which a threshold must sign: atlas.getSignerPolicy returns its threshold and members.
Owner key: cold
The owner key moves money out of the wallet and decides who may act. It alone signs setInstructionKey (bind or remove a key), createSubAccount, setStpLevel, rotateOwnerKey, transfer (to an account of this wallet or another), withdraw, and the onboarding signatures. The key of the address a wallet was opened at is its first owner key; rotateOwnerKey replaces it. It signs no trading: no order, no cancel, no stake and no internalTransfer, unless it is bound to the account as an instruction key (below). To move money between its own accounts unbound, it signs transfer.
Instruction key: hot
An instruction key acts on one account through a binding the owner key signs with setInstructionKey. Each binding has its own scope: INSTRUCTION_KEY_SCOPE_FULL (every trading command, isolated margin, internal transfers, stake and unstake) or INSTRUCTION_KEY_SCOPE_REDUCE_ONLY (cancels, mass cancel, the dead-man switch and reduce-only perp orders). No scope can withdraw, transfer to another wallet or manage keys.
- To trade with the owner key, bind it. The owner key places, cancels and replaces orders only on an account it is bound to as an instruction key, like any other key. Unbound, its trading actions are refused
28(Signer key not permitted), or24(Signer key not found) on a sub-account. Binding it as an instruction key gives it a second, separate nonce slot on that account. - Bindings are per account. Bind a key to Main and to Sub A with two
setInstructionKeysignatures; each binding carries its own scope, Builder Fee caps and nonce mode. See Instruction keys. - Every command names its account by address, and every envelope names its
authorityand itssigner. The server recovers the key from the signature, checks that it is thesigner, thatauthorityis the account whose authority the command exercises, and that the signer may act for it. Knowing an address proves nothing. atlas.getKeyslists a wallet's owner-key nonce and every bound key with its bindings.
Who signs what
| Command | Signed by |
|---|---|
placeOrder, replaceOrder | A key bound to the account. An INSTRUCTION_KEY_SCOPE_REDUCE_ONLY binding places and replaces reduce-only perp orders only |
cancelOrder, cancelAllOrders, cancelAllOrdersAfter | A key bound to the account, either scope. An INSTRUCTION_KEY_SCOPE_REDUCE_ONLY key can arm or shorten the dead-man clock, never turn it off or lengthen it |
moveIsolatedMargin, internalTransfer, stake, unstake | A key bound to the account with INSTRUCTION_KEY_SCOPE_FULL |
setInstructionKey, createSubAccount, setStpLevel, rotateOwnerKey, transfer, withdraw | The owner key |
Onboarding: the bind sent with atlas.sendWalletReadyRequest, and the message TermsAcceptance | The owner key |
setAdvanceInstructionKey | The owner key |
createTpSlOrder, updateTpSlOrder, cancelTpSlOrder, createTwapOrder, cancelTwapOrder, cancelAllTwaps | The owner key, or a key bound with setAdvanceInstructionKey |
Open an account and enable trading
There is no registration step and no activation fee. A deposit waits at the address it was sent to. The first command your key signs for that address opens the wallet there: Main is created at your address, takes what waited there as its cash, and your key becomes its owner key. Until then the funds show in atlas.getBalances but there is no wallet.
A new wallet is pending until it accepts the Atlas Terms of Use. One owner signature does all of it: it opens the wallet, binds your app's instruction key, and accepts the terms.
Derive your address
Main's address is your key's Ethereum-style address. You can compute it offline before anything exists on ATLAS.
Deposit to it
Send any asset the venue lists to that address. There is no minimum and no fee. It waits there unclaimed.
Read the terms in force
atlas.getTermsreturns the one Atlas Terms of Use version in force: itsid,versionandcontentHash. Fetch the text fromdocumentUrland check its keccak256 before you show it.Sign one bind and send it
With the owner key, sign a
setInstructionKeybind of your instruction key whosestatementsaccept the terms. Send it withatlas.sendWalletReadyRequestas["enableTrading", rawTx, statements]onPOST /seq/tx. The/seq/wshandshake refuses an address that has no account yet, so use HTTP for this first call.
Enable trading
The bind sent with atlas.sendWalletReadyRequest is Enable Trading: one signature for the whole wallet, Main and every sub-account, now or later. It charges nothing. On success the wallet is active: atlas.getAccountState shows walletState: "active" on every account of the wallet, and the bound key can trade. Orders sent before then are refused 30 (Wallet pending).
The statements
statements are the lines the owner reads and accepts with the bind, in exactly this order:
label | value | |
|---|---|---|
Atlas Terms of Use | <id>@<version> 0x<contentHash>, from atlas.getTerms | Required |
Builder | A Builder ID to stamp on the wallet, 0x + 40 lowercase hex | Optional |
Request | enableTrading or enableBuilder: the kind of the request | Optional for enableTrading, required for enableBuilder |
{
"jsonrpc": "2.0",
"id": 1,
"method": "atlas.sendWalletReadyRequest",
"params": [
"enableTrading",
"0x0011000080ebf39fd6e51aad88f6f4ce6ab8827279cfffb92266…",
[
{ "label": "Atlas Terms of Use", "value": "atlas-terms-of-use@1 0x28ef6460e39d51d0c9d9dc3c3635503ae039fbd91913cc43839e367bd7690120" },
{ "label": "Request", "value": "enableTrading" }
]
]
}- Any other label, order or duplicate is refused
-32602, and so is alabelover 64 bytes or avalueover 256. - The bind signs only a commitment to the lines (EIP-712's hash of a
Statement[]), so you send the full text alongside. A text other than the one signed fails the signature,-20009. - The bind's nonce is the owner slot's next gapless nonce, with an
expires_atwithin the gapless bounds:1for a wallet not yet open, orownerKeyNonce+ 1 fromatlas.getKeysfor one that is. A bind whose expiry has passed is refused-12023(Signature expired). - A terms line that doesn't name the version in force is refused
-20010(Unknown terms),-20011(Terms hash mismatch) or-20012(Terms not in force). - After a timeout or a lost answer, send the same request again. Every step repeats harmlessly.
The answer is enableTradingApplied, with stampedAtMs, the time the bind was stamped. After an interrupted request or a refused bind, read atlas.getAccountState and atlas.getKeys before you retry: the wallet can be active without the key bound. With kind enableBuilder the same signature also issues your Builder ID and the answer is enableBuilderApplied.
Signed messages
A wallet that is already open signs messages rather than a bind, and sends their bytes with atlas.sendRawMessage ("params": ["0x…"]):
TermsAcceptanceaccepts a new terms version without binding a key. It haschainId,wallet, the samestatements, andexpiresAtin Unix seconds, which must be in the future and at most one day ahead.- To become a builder, send the bind with
atlas.sendWalletReadyRequestandkindenableBuilderoverPOST /seq/tx, not a message. From an active wallet, sign it at the owner slot's next gapless nonce. It can bind a new key, or a key already bound to Main if it names that binding'snonceMode(another is refused20); it then replaces the binding's scope and Builder Fee Caps.
A message has no nonce. It signs Typed under the message domain, and its first three members are bytes1 sigSuite (the scheme byte, 0x11), bytes2 selector (the message's selector: 0xad67 for TermsAcceptance) and uint32 chainId (the Atlas chain ID):
TermsAcceptance(bytes1 sigSuite,bytes2 selector,uint32 chainId,address wallet,Statement[] statements,uint64 expiresAt)Statement(string label,string value)Its bytes are laid out like a transaction envelope without authority or a nonce: 0x00, the scheme byte, chainId (4 bytes), the signer (20), the selector (2), the fields in order (a list or text as a count then its items), then, for Typed, the 8-byte domain chain ID, 0x41 and the 65-byte signature. A message for an address with no wallet yet is refused 115 (Wallet not found): onboard with the bind instead.
For TermsAcceptance the fields are wallet (20 bytes), statements (a count of lines, then each line's label and value, each a count of its UTF-8 bytes and then those bytes) and expiresAt (a big-endian u64). In the Typed digest, statements hashes as in Statements hash.
Example: a terms acceptance
From the protocol's message golden vectors: one terms line, expiresAt 1700086400, signed Typed at domain chain ID 33003 by the test key of thirty-two 0x07 bytes (address 0x4a62316623ad457f02cdc5d997ded67a383ec569) for the wallet 0x1111…1111. Its expiry has passed and its wallet isn't the signer's, so use it to check your bytes and digest, never send it. Never use that key for anything else.
00 transaction type
11 scheme: Typed
000080eb chainId: 33003
4a62316623ad457f02cdc5d997ded67a383ec569 signer
ad67 selector: TermsAcceptance
1111111111111111111111111111111111111111 wallet
01 statements: 1 line
12 label: 18 bytes
41746c6173205465726d73206f6620557365 "Atlas Terms of Use"
60 value: 96 bytes
61746c61732d7465726d732d6f662d75736540323032362d31302d303120 "atlas-terms-of-use@2026-10-01 "
307861626162616261626162616261626162616261626162616261626162616261 "0xabab…"
626162616261626162616261626162616261626162616261626162616261626162 "…abab"
0000000065554280 expiresAt: 1700086400
00000000000080eb domain chain ID: 33003
41 proof length: 65
f0fd2c923e9f9e866377ac9069049a5e90bb06ced01c4f5a4c8b2e88331f9b65 r
5ba8919fa697b4055dc26aa9d051ae7a42bba5973e260dc0bbb87a2e9ff06c3c s
01 vstructHash:0xa91838638bd61dc581b6e500bb42c3e1c6ba289cce4dc3746b36eb819c012c1e.signingHash, under the message domain at domain chain ID 33003:0x445b51dc3962138dda1be4d58d5fc2f73c90dffc7845c6e963b8f7d08b7eea2a.
Signing domains
Every EIP-712 signature uses the same domain type, with one of four salts. The salts are the same in every deployment: what tells deployments apart is the Atlas chain ID each transaction, sign-in, login and message signs as a field of its own. The salt keeps the kinds apart, so a sign-in or a message can never be replayed as a transaction.
EIP712Domain(string name,string version,uint256 chainId,bytes32 salt)| Domain | name | version | chainId | salt | Used by |
|---|---|---|---|---|---|
| Transaction | atlas | "1" | The domain chain ID: the chain your wallet signs at | keccak256("atlas") = 0xb7d6c242d4540c764ba9e759f9bb318a9ca9c855fed6042f495d287cb9cd8d7b | Every Typed transaction to the venue |
| Message | atlas | "1" | The domain chain ID | keccak256("atlas/message") = 0x0b5873bb429980cb4a1d5c447764f2f2739fd05490b8ac751d5b3cba3e58c5d8 | The /seq/ws handshake, auth.signIn, auth.login, TermsAcceptance, and the new-key proof of rotateOwnerKey, which always signs at chain ID 33003, the Atlas chain ID, not your wallet's chain |
| Advanced orders | atlas | "1" | The domain chain ID | keccak256("atlas/oms") = 0x544f3ca127b04fe03bc2a496b90dc6fe33455b498edcf062397898bb2e1087f9 | TP/SL, TWAP and setAdvanceInstructionKey. See Advanced orders |
| Advanced-order reads | atlas | "1" | The domain chain ID | keccak256("atlas/oms/message") = 0x9311f5904f2bc44d83812f65002538274c5401c02d43414cf8da75b9b1c91992 | The OMS-Read authorization. See Advanced orders |
There are two chain IDs, and they do different jobs:
- The Atlas chain ID is the deployment's zone id: 33003. A transaction signs it as its first field,
chainId, andauth.signIn,auth.loginand the signed messages sign it too. Any other is refused246(Atlas chain id mismatch).atlas.getVersionreturns it assigning.chainId. - The domain chain ID is the EIP-712 domain's
chainId: whatever chain the signing wallet is on. You send it with the signature (in a Typed envelope, asdomainChainIdon sign-in and login, aschain_idin the handshake). It can be any chain, so a browser wallet can sign without switching networks.
atlas.getVersion returns the transaction domain's name, version and salt as signing.transactionDomain.
- Transaction domain at domain chain ID 33003: separator
0xe0e97202f14bcda4ed7c24f5dded18d85650617ac46c68ce41061bd185143a47. - Message domain at domain chain ID 33003: separator
0x61127394f706a3eb01b1c79f18d9ae294317a81ef5fde3c10001ac64fae4c2f9. - If yours differs, check the salt and that
chainIdis hashed as auint256.
Add the network to a wallet
You don't need the network to sign. To show it in a browser wallet anyway, add chain ID 33003 with the RPC URL https://api.atlas.layerzero.network/zone-rpc (no API key) and currency ZRO. It takes no transactions and reports no balances: trade on /seq/tx and read from /account/rpc.
Sign in to a WebSocket
Sign-in opens a session for private reads on an /account/ws connection. It is a two-call handshake signed by the owner key, and the account stays bound to the connection until it closes. Streams says which streams need it.
The examples on this section are real signatures: Atlas chain ID 33003, signed under the message domain at domain chain ID 33003 with the well-known test key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 (address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266). Use them to check your own signing code. Never use that key for anything else.
- GET /account/ws · upgrade
- auth.challenge{…}
- result · challenge{…}single-use, held briefly
- sign EIP-712 SignInoffline: chainId, sender, challenge, scopeHash, under the message domain
- 65-byte signature
- auth.signIn{…}
- Checks the signature against the owner key and consumes the challenge
- result · signed in{…}
- The account stays bound to this connection until it closes
—
The signed message
domain = { name: "atlas", version: "1", chainId: domainChainId, salt: keccak256("atlas/message") }
typeHash = keccak256("SignIn(uint32 chainId,address sender,bytes32 challenge,bytes32 scopeHash)")
scopeHash = keccak256("indexer.read")
structHash = keccak256(typeHash ‖ pad32(chainId) ‖ pad32(accountAddress) ‖ challenge ‖ scopeHash)
signingHash = keccak256(0x19 0x01 ‖ domainSeparator ‖ structHash)chainId is the Atlas chain ID: a sign-in for another is refused 246. scopeHash ties the signature to sign-in, and the message domain's salt differs from the transaction domain's: a sign-in signature cannot be replayed as a login or a transaction. The address fills the low 20 bytes of its 32-byte word. For the example above, signingHash is 0xa82a30f9a9343b5de18bfd233b064a4154ce0a09e395c35f7fe84c9971ea011f.
auth.challenge
auth.challengeWebSocket/account/wsReturns a single-use 32-byte challenge. Takes no params: leave params out, or send {}. Sign and send auth.signIn straight away: the server only holds challenges briefly. Over HTTP the same method issues a challenge for auth.login instead.
Challenge
challengestringrequired- 32 random bytes as
0x+ hex,^0x[0-9a-fA-F]{64}$. Single-use:auth.signInorauth.loginconsumes it.
auth.signIn
auth.signInWebSocket/account/wsaccountAddressAccountAddressrequired- The account to sign in as:
0x+ 40 hex. challengestringrequired- The value from
auth.challengeon this connection.^0x[0-9a-fA-F]{64}$. chainIdintegerrequired- The Atlas chain ID the sign-in is for, a JSON integer: 33003. The first member of the signed
SignIn. domainChainIdUint256Stringrequired- The EIP-712 domain
chainIdyou signed under, as a decimal string. signaturestringrequired- The EIP-712
SignInsignature:0x+ 65 bytes,r ‖ s ‖ vwithvin {0, 1}.^0x[0-9a-fA-F]{130}$.
SignInResponse
successbooleanrequired- Always
true. Failures are JSON-RPC errors. authedAccountAddressAccountAddressrequired- The account now bound to this connection.
| Error | When |
|---|---|
-12018 (Challenge required) | No auth.challenge was issued on this connection |
-12013 (Challenge invalid) | The challenge is not the one issued on this connection |
-12012 (Challenge expired), -12014 (Challenge used) | The challenge has lapsed, or was already consumed |
-12016 (Authentication failed), -20009 (Invalid signature) | The signature does not recover to the owner key, or does not verify |
-12010 (Account mismatch) | The account does not match what was signed |
-12017 (Already authenticated) | The connection is already signed in (also on auth.challenge) |
246 (Atlas chain id mismatch) | chainId isn't this deployment's Atlas chain ID |
-32602 | Wrong hex length, a malformed accountAddress, chainId or domainChainId |
-20003 | Sign-in is unavailable right now. Retry with backoff |
Each connection signs in once. A challenge is only valid on the connection that issued it. To sign in as another account, open a new connection.
HTTP sessions
A few reads are private: atlas.getBuilderUsers, atlas.getBuilderPayouts and atlas.getStakingState need an Authorization: Bearer <accessToken> header. You get the token by signing in over HTTP on POST /account/rpc: auth.challenge, then auth.login. Renew it with auth.refresh and end the session with auth.logout. A token never authorizes a write: every write is still signed.
Get a challenge
auth.challengeonPOST /account/rpc. Over HTTP the challenge is not tied to a connection, and expires 60 seconds after it is issued.Sign Login and log in
Sign
Loginwith the owner key or a key bound to the account, and send it withauth.login. You get an access token (one hour) and a refresh token (the session lasts seven days).Read, refresh, log out
Send
Authorization: Bearer <accessToken>on each private read. BeforeexpiresAt, swap the refresh token for a new pair withauth.refresh. End the session withauth.logout.
domain = { name: "atlas", version: "1", chainId: domainChainId, salt: keccak256("atlas/message") }
typeHash = keccak256("Login(uint32 chainId,address sender,bytes32 challenge,bytes32 scopeHash)")
scopeHash = keccak256("atlas.session")
structHash = keccak256(typeHash ‖ pad32(chainId) ‖ pad32(accountAddress) ‖ challenge ‖ scopeHash)
signingHash = keccak256(0x19 0x01 ‖ domainSeparator ‖ structHash)The scope differs from SignIn's, so neither a WebSocket sign-in nor a transaction signature can be replayed as a login.
auth.login
auth.loginHTTP/account/rpcaccountAddressAccountAddressrequired- An account the signing key may act for.
challengestringrequired- The value from HTTP
auth.challenge. Consumed on success. chainIdintegerrequired- The Atlas chain ID the login is for, a JSON integer. The first member of the signed
Login. domainChainIdUint256Stringrequired- The EIP-712 domain
chainIdyou signed under. signaturestringrequired- The EIP-712
Loginsignature,0x+ 65 bytes,r ‖ s ‖ v.
LoginResponse
accessTokenstringrequired- A JWT. Send it as
Authorization: Bearer <accessToken>. tokenTypestringrequiredBearer.expiresAtTimestampMsrequired- When the access token expires: one hour after issue, never after
refreshExpiresAt. refreshTokenstringrequired0x+ 64 lowercase hex. Usable once. Not a JWT; send it only toauth.refreshandauth.logout.refreshExpiresAtTimestampMsrequired- When the session ends: seven days after
auth.login. A session fromauth.redeemHandoffends when the source access token used to create the code expires, or when the source session ends, whichever comes first. A refresh extends neither. walletAddressAccountAddressrequired- The wallet that holds the covered accounts.
accountAddressesAccountAddress[]required- The accounts the token may read.
keyKindenumrequiredowner_key: the token covers every account of the wallet.bound_key: only the accounts the key is bound to. Every private read takes either, as long as the token covers the account it reads.
Each private read rechecks the key against current state: rotating the owner key, or removing a key's binding, revokes what it granted at once. Errors: 246 (chainId isn't this deployment's), -12012 (challenge expired), -12015 (unknown account), -12016 (authentication failed), -20009 (invalid signature), -32602, -20003.
auth.refresh
auth.refreshHTTP/account/rpcTakes refreshToken and returns a new LoginResponse, without another signature. The presented refresh token is spent at once. Presenting a spent one again revokes the whole session, so don't retry a refresh whose response was lost: if the first attempt applied, the retry ends the session. The covered accounts can shrink, never grow. Errors: -12021 (refresh token invalid), -12022 (refresh token reused, session revoked).
auth.logout
auth.logoutHTTP/account/rpcTakes refreshToken, ends its session and revokes every access token issued for it. Other sessions are unaffected. Idempotent: an unknown or already-ended session also returns { "success": true }.
auth.createHandoff
auth.createHandoffHTTP/account/rpcPasses a read session to a related app, such as from your web app to your Builder Portal, without asking the wallet to sign again. Send it with the Authorization: Bearer <accessToken> of a live session. It takes codeChallenge, the receiving browser's RFC 7636 S256 challenge (BASE64URL-NO-PAD(SHA256(codeVerifier)) over a verifier that browser created and keeps), and returns { code, expiresAt }: a single-use code of 64 lowercase hex characters with no 0x, that expires at most 60 seconds after issue and never after the source token or session.
Put the code in the redirect, never the access token. A code grants reads only: no session ever authorizes a write. Errors: -20002, -12009, -12019, -12020, -32602, -20003.
auth.redeemHandoff
auth.redeemHandoffHTTP/account/rpcTakes code and codeVerifier (the verifier whose challenge the code was issued for) and returns a new LoginResponse: a session of its own, with its own refresh token, covering at most what the source session covered. It inherits the source's key and keyKind, and ends when the source access token used to create the code expires, or when the source session ends, whichever comes first. The code is consumed in the same step. An unknown, expired, already redeemed or wrong-verifier code is refused -12025 (Handoff code invalid) and nothing is consumed. The two sessions refresh and log out independently.
Private reads refuse a missing token with -20002, an expired one with -12019, a bad one with -12020, and a token that doesn't cover the account, or comes from a key kind the read doesn't accept, with -12009 (Forbidden).
Connect to the trading gateway
Every write works over HTTP: POST /seq/tx. The trading WebSocket at /seq/ws is optional: it takes the same atlas.sendRawTransaction, atlas.sendWalletReadyRequest (except kind enableBuilder, HTTP only) and atlas.sendRawMessage and answers the same results over one connection. It has its own handshake: the first text frame after the upgrade must be a signed RetailWsHandshake object. It is raw JSON, not a JSON-RPC request. Nothing is pushed on the connection: follow your orders and fills on stream.orders over /account/ws.
{
"purpose": "gateway-rest/ws/v2",
"account_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"nonce": 7,
"ts_ms": 1791210612345,
"chain_id": "33003",
"signature": [243, 141, 54, 152, 149, 38, 82, 27, 88, 111, 137, 190, 236, 119, 212, 46, 163, 95, 11, 47, 89, 105, 25, 150, 93, 82, 15, 43, 53, 46, 243, 134, 31, 174, 177, 173, 134, 155, 233, 136, 182, 171, 196, 12, 179, 152, 76, 93, 2, 87, 243, 34, 174, 110, 31, 30, 104, 80, 139, 73, 59, 150, 88, 66, 1]
}RetailWsHandshake
purposestringrequired- Exactly
"gateway-rest/ws/v2". Anything else is rejected. account_addressAccountAddressrequired- The account to trade,
0x+ 40 hex. The account must already exist: an address with no account is refused with-10009, so onboard overPOST /seq/txfirst. Sign with the owner key or a key bound to the account. nonceintegerrequired- A u64 you choose, bound into the signature. A bare JSON integer.
ts_msintegerrequired- Your current Unix time in milliseconds, a bare JSON integer. Must be within ±60 seconds of the server's clock.
chain_idUint256Stringrequired- The EIP-712 domain
chainIdyou signed under, as a decimal string. signatureSignature65required- 65 integers,
r ‖ s ‖ v, over theRetailWsHandshakedigest.
The signature covers RetailWsHandshake(string purpose,address accountAddress,uint64 nonce,uint64 tsMs) under the message domain, with purpose hashed as a string and the address in the low 20 bytes of its word. The frame above is signed with the test key from Sign in to a WebSocket at domain chain ID 33003; its digest is 0x7a7a014443a44143110c0c429b3947c75b478c1125314d10dfd4ba0158cd730f. Note the snake_case field names in the frame, unlike the rest of the API.
Send the handshake within 10 seconds of the upgrade, in at most 4,096 bytes. A successful handshake gets no reply; you can send your first write straight after it.
A failed handshake gets one JSON-RPC error with "id": null, then the connection closes with code 1008 and the reason "<code> <message>":
| Code | Why |
|---|---|
-32700 | The frame is not JSON |
-32600 | A binary, non-text or oversized frame |
-32602 | Fields don't decode (for example a missing chain_id), or a wrong purpose |
-20009 | The signature does not verify |
-10009 | The account is unknown: onboard over POST /seq/tx first. Otherwise retry with backoff |
-10018 | No handshake before the 10-second timeout |
-10019 | ts_ms outside the freshness window |
-20001 | Rate limited, with error.data.retryAfterMs when known |
The handshake grants no authority by itself: every write is a signed envelope, checked on its own signature. A handshake signature cannot be replayed as one: the salt and the signed type both differ.
Sign a transaction
Every write is one signed transaction: Transaction {chainId, authority, signer, nonce, command}, signed, encoded as bytes, and sent as the only positional param of atlas.sendRawTransaction. There is no JSON form.
{ "jsonrpc": "2.0", "id": 7, "method": "atlas.sendRawTransaction", "params": ["0x0011000080ebf39fd6e51aad88f6f4ce6ab8827279cfffb92266…"] }Send it to POST /seq/tx, or on /seq/ws after the handshake. Both take every public command and answer the same result.
chainIdis the Atlas chain ID: 33003. A transaction for any other is refused246(Atlas chain id mismatch), so a transaction signed for another deployment can never apply here.authorityis the account whose authority the command exercises: the account the command names or, for a command only the owner key may sign, that account's wallet's Main. Any other is refused329(Authority mismatch), and a signature made for one authority doesn't verify for another.signeris the address of the key that signs. A signature that recovers to any other key is refused.
The envelope
rawTx is 0x + the hex of these bytes, in order. Bytes after the signature are refused.
| Bytes | Field | |
|---|---|---|
| 1 | Transaction type | Always 0x00 |
| 1 | Scheme byte | 0x11 Typed or 0x01 Opaque. See The signature |
| 4 | chainId | The Atlas chain ID, big-endian u32: 0x000080eb |
| 20 | authority | The account whose authority the command exercises |
| 20 | signer | The signing key's address |
| 17 or 9 | nonce | A tag byte, then big-endian u64s: 0x00 ‖ gapless_nonce ‖ expires_at for a gapless slot, or 0x01 ‖ time_stamp_nonce for an increasing one. See Nonce |
| 2 + n | command | The command's 2-byte selector, then its fields. See Action encoding |
| 8 | Domain chain ID | Typed only: the EIP-712 domain chainId you signed at, big-endian u64. Absent for Opaque |
| 1 | Proof length | 0x41: the proof's length, 65, as a VLQ. One byte for a single-key signature |
| 65 | Signature | r ‖ s ‖ v |
The transaction bytes, from chainId to the end of the command, are the same under either scheme. You build them yourself: the next section gives every command's layout.
Action encoding
command is the command's 2-byte selector, then its fields in a fixed binary layout. The selector says which command follows. The fields have no names, tags or padding; each is written in the order its table lists, using these rules:
| Type | Encoding |
|---|---|
Integers (u8, u32, u64, i64, i128) | Fixed width, big-endian. Signed integers are two's complement |
| Decimals | The integer mantissa at the field's scale: quantities × 10⁸, prices × 10¹⁰, amounts × 10¹², Builder Fee rates and caps in bps × 10⁸. "50" as an amount is 50000000000000. A digit past the scale is refused, never rounded |
| Addresses | 20 bytes |
Ids and fixed-size bytes (clientOrderId, a transfer's 64-byte memo, statements, receiver) | As they are, at their fixed size |
bool | 1 byte: 0 or 1 |
A choice (side, timeInForce, marginMode, kind, target, …) | A 1-byte tag, then that choice's own fields, if any |
| A market | A tag, 0 spot or 1 perp, then the market's number as a u32: 5 bytes. {"PERP": {"id": 1}} is 01 00000001 |
| An optional field | 0, or 1 and then the value |
A list, or variable-length bytes (a withdrawal's memo) | A count, then the items. The count is a VLQ in its shortest form: 7 bits a byte, most significant group first, the high bit set on every byte but the last, 1 to 5 bytes. A count under 128 is one byte |
The decoder takes exactly one encoding of each command, and only a list carries a length, so a missing or extra byte shifts everything after it. Bad bytes are refused before anything runs: usually -20009 (Invalid signature), or 1 (Envelope malformed) for bytes after the signature or a command that doesn't decode, such as a tag that doesn't exist or a bool other than 0 or 1, or 218 (Selector not found) for a selector that names no command.
Example: a transfer
A transfer of 50 USDT (asset 1) from Main to another wallet, with the memo ord-42, signed at Atlas chain ID 33003 by the owner key with gapless nonce 1 and expires_at 1800000000, at domain chain ID 33003. It uses the well-known test key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 (address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266); never use that key for anything else. The owner key's account is Main, so authority, signer and account are all the same address.
{
"chainId": 33003,
"authority": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"signer": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"nonce": { "gapless_nonce": "1", "expires_at": "1800000000" },
"command": {
"transfer": {
"account": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"toAccount": "0x71d4b8e2a5c9f3b6d0e7a1c4f8b2d5e9a3c6f0b4",
"asset": 1,
"amount": "50",
"memo": "0x6f72642d343200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
}
}00 transaction type
11 scheme: Typed
000080eb chainId: 33003
f39fd6e51aad88f6f4ce6ab8827279cfffb92266 authority
f39fd6e51aad88f6f4ce6ab8827279cfffb92266 signer
00 0000000000000001 000000006b49d200 nonce: gapless, 1, expires_at 1800000000
6e61 selector: transfer
f39fd6e51aad88f6f4ce6ab8827279cfffb92266 account
71d4b8e2a5c9f3b6d0e7a1c4f8b2d5e9a3c6f0b4 toAccount
00000001 asset: 1
000000000000000000002d79883d2000 amount: 50 × 10¹² as an i128
6f72642d34320000000000000000000000000000000000000000000000000000 memo bytes 0–31
0000000000000000000000000000000000000000000000000000000000000000 memo bytes 32–63
00000000000080eb domain chain ID: 33003
41 proof length: 65
c305a9f6ca3869eecc68651440647398ed38201aa7fdd0fc53430ff46ce2f7d7 r
1d165d747da37431fab5c900323c81b0aea1d3483c26f3fe3e1711bcc53f920b s
01 vA transfer is Typed only, so the signature is over its EIP-712 digest (see Typed signing), which uses the same values. The memo signs as bytes, the keccak256 of its 64 bytes:
encodeType AtlasTransaction(uint8 txType,bytes1 sigSuite,Transaction_Gapless transaction)Nonce_Gapless(bool Gapless,uint64 gapless_nonce,uint64 expires_at)Transaction_Gapless(uint32 chainId,address authority,address signer,Nonce_Gapless nonce,bytes2 selector,Transfer command)Transfer(address account,address toAccount,uint32 asset,int128 amount,bytes memo)
domainSeparator 0xe0e97202f14bcda4ed7c24f5dded18d85650617ac46c68ce41061bd185143a47 name "atlas", version "1", chainId 33003, salt keccak256("atlas")
structHash 0xbcb78bbf30efbc316a24518919e601a9bc612496f3724e3be1c6ab097e404639
signingHash 0x9536c8683d4a1e4ca1151d102100693d06697915acf9e6aae652bc0bdba6d62eThe signing hash is the transaction's txId, and the transferId ATLAS returns. A key held in a KMS or HSM signs this 32-byte hash as a raw digest, not as a message: convert its DER signature to r ‖ s, normalise s to the lower half of the curve order, and find v (0 or 1) by recovering the key and comparing it with signer.
0x0011000080ebf39fd6e51aad88f6f4ce6ab8827279cfffb92266f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000001000000006b49d2006e61f39fd6e51aad88f6f4ce6ab8827279cfffb9226671d4b8e2a5c9f3b6d0e7a1c4f8b2d5e9a3c6f0b400000001000000000000000000002d79883d20006f72642d34320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080eb41c305a9f6ca3869eecc68651440647398ed38201aa7fdd0fc53430ff46ce2f7d71d165d747da37431fab5c900323c81b0aea1d3483c26f3fe3e1711bcc53f920b01Statements hash
A setInstructionKey bind carries its statements as 32 bytes: the keccak256 of the lines' EIP-712 struct hashes, concatenated in order. Each line hashes as keccak256(keccak256("Statement(string label,string value)") ‖ keccak256(label) ‖ keccak256(value)). With no lines it is keccak256(""). This is the same value the Typed digest uses for the Statement[] field. The statement text itself travels beside the transaction, in atlas.sendWalletReadyRequest.
Every action's layout
Every field's JSON name is the one on Trading, except in the advanced-order tables, which use the signed names: on Trading, takeProfit and stopLoss are tp and sl, price is limitPrice and quantity is baseQty. The sizes below are after the 2-byte selector.
Byte layouts for every command
placeOrder, selector 0x61cd:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
marketId | 5 | market: tag 0 spot or 1 perp, then a u32 |
clientOrderId | 16 | 16 bytes |
side | 1 | 0 buy, 1 sell |
quantity | 8 | i64: quantity × 10⁸ |
orderType | 1 or 10 | 0 limit, then price (i64: price × 10¹⁰) and postOnly (0 or 1). 1 market, with nothing after it |
timeInForce | 1 | 0 ioc, 1 gtc, 2 fok |
marginMode | 1, 2 or 18 | 0 cross. 1 isolated, then openingMargin: 0 if absent, or 1 and an i128 (amount × 10¹²) |
reduceOnly | 1 | 0 false, 1 true |
builderFee | 1 or 29 | 0 if absent, or 1, appBuilderId (20 bytes) and builderFeeBps (i64: bps × 10⁸) |
cancelOrder, selector 0x655f:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
clientOrderId | 16 | 16 bytes |
marketId | 5 | market |
target | 9 or 17 | 0 and orderId (the bare sequence) as a u64, or 1 and a 16-byte clientOrderId |
replaceOrder, selector 0x2b8f:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
marketId | 5 | market |
target | 9 or 17 | 0 and orderId as a u64, or 1 and a 16-byte clientOrderId |
clientOrderId | 16 | 16 bytes |
quantity | 8 | i64: quantity × 10⁸ |
price | 8 | i64: price × 10¹⁰ |
postOnly | 1 | 0 false, 1 true |
reduceOnly | 1 | 0 false, 1 true |
cancelAllOrders, selector 0xceb1:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
clientOrderId | 16 | 16 bytes |
marketId | 5 | market |
cancelAllOrdersAfter, selector 0xb301:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
timeoutSeconds | 4 | u32 seconds |
moveIsolatedMargin, selector 0x168e:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
marketId | 5 | market |
direction | 1 | 0 add, 1 remove |
amount | 16 | i128: amount × 10¹² |
internalTransfer, selector 0x9bf9, and transfer, selector 0x6e61:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
toAccount | 20 | address |
asset | 4 | u32 |
amount | 16 | i128: amount × 10¹² |
memo | 64 | 64 bytes; zero bytes when there is none |
stake, selector 0x4472, and unstake, selector 0x3a04:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
asset | 4 | u32 |
amount | 16 | i128: amount × 10¹² |
withdraw, selector 0xb21d:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
asset | 4 | u32 |
amount | 16 | i128: amount × 10¹² |
destinationZone | 4 | u32 |
receiver | 32 | 32 bytes; an EVM address is left-padded with zeros |
memo | 1 + n or 2 + n | a VLQ count (2 bytes from 128), then up to 255 bytes |
setInstructionKey, selector 0xef2b:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
instructionKey | 20 | address |
change | 1 or 51 | 0 bind, then scope (u8: 2 reduce only, 3 full), builderFeeCap.perpBps and builderFeeCap.spotBps (each i64: bps × 10⁸), nonceMode (u8: 0 gapless, 1 increasing) and statements (32 bytes, above). 1 remove, with nothing after it |
createSubAccount, selector 0x0764:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
binding | 1 or 39 | 0 if absent, or 1, instructionKey (20 bytes), scope (u8), builderFeeCap.perpBps and builderFeeCap.spotBps (each i64: bps × 10⁸) and nonceMode (u8), as in a bind |
setStpLevel, selector 0xd9d6:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
level | 1 | 0 account, 1 wallet |
rotateOwnerKey, selector 0x186b:
| Field | Bytes | Encoding |
|---|---|---|
account | 20 | address |
newOwnerKey | 1 or 21 | 0 for none, or 1 and the 20-byte address |
newOwnerKeyProof | 1, or 2 + 66 per signature | 0 for none, or 1, a count, then each signature as the scheme byte 0x11, r (32), s (32) and v (1). A single-key owner sends one |
setAdvanceInstructionKey, selector 0x823f:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
instructionKey | 20 | address |
change | 1 or 65 | 0 bind, then the omsDelegateKey's X and Y coordinates (32 bytes each). 1 remove, with nothing after it |
createTpSlOrder, selector 0x9032:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
marketId | 5 | market |
clOrdId | 16 | 16 bytes |
marginMode | 1 | 0 cross, 1 isolated |
takeProfit, stopLoss | 1, 13 or 21 each | 0 if absent, or 1 and a plan: triggerRef (u8: 0 mark, 1 index, 2 last), triggerPrice (i64: price × 10¹⁰), orderType (u8: 0 limit, 1 market), timeInForce (u8: 0 ioc, 1 gtc), and price: 0, or 1 and an i64 for a limit order |
entry | 1, 15, 23, 31 or 39 | 0 if absent, or 1, side (u8: 0 buy, 1 sell), quantity (i64: quantity × 10⁸), orderType, timeInForce and price as in a plan, postOnly (0 or 1), and openingMargin: 0, or 1 and an i128 (amount × 10¹²) |
builderFee | 1 or 29 | 0 if absent, or 1, appBuilderId (20 bytes) and builderFeeBps (i64: bps × 10⁸) |
updateTpSlOrder, selector 0xf9d9:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
target | 9 or 17 | 0 and parentOrderId as a u64, or 1 and the 16-byte origClOrdId |
clOrdId | 16 | 16 bytes |
takeProfit, stopLoss | 1, 13 or 21 each | as in createTpSlOrder |
cancelTpSlOrder, selector 0x846a:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
target | 9 or 17 | as in updateTpSlOrder |
slot | 1 | 0 take profit, 1 stop loss, 2 both |
clOrdId | 16 | 16 bytes |
createTwapOrder, selector 0x33bc:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
marketId | 5 | market |
clOrdId | 16 | 16 bytes |
marginMode | 1 | 0 cross, 1 isolated |
twap | 14 | side (u8: 0 buy, 1 sell), quantity (i64: quantity × 10⁸), durationSeconds (u32) and reduceOnly (0 or 1) |
builderFee | 1 or 29 | as in createTpSlOrder |
cancelTwapOrder, selector 0x84ae:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
target | 9 or 17 | as in updateTpSlOrder |
clOrdId | 16 | 16 bytes |
cancelAllTwaps, selector 0x8208:
| Field | Bytes | Encoding |
|---|---|---|
accountAddress | 20 | address |
clOrdId | 16 | 16 bytes |
Advanced orders
TP/SL, TWAP and setAdvanceInstructionKey use the same envelope and atlas.sendRawTransaction, but sign differently:
- Typed only, under the advanced-order domain: salt
keccak256("atlas/oms"). The type string has noAtlasTransactionwrapper and no selector: forcancelAllTwapsit isTransaction(uint32 chainId,address authority,address signer,Nonce_Gapless nonce,CancelAllTwaps action), then every referenced type sorted by name. Every command's string is on Trading. - A gapless nonce per signer, with an
expires_at: one sequence for all of that key's advanced-order requests, on every account, separate from its venue nonce slots.
Signature, nonce and envelope errors are the same as for any transaction. Their results, the next nonce and the signed OMS-Read header that advanced-order reads need are on Trading: Advanced orders and Read authorization.
The signature
The signature is a scheme byte in the envelope, then the 65-byte secp256k1 signature r ‖ s ‖ v. v is the raw recovery id, 0 or 1: wallet-style 27/28 is refused. s must be in the lower half of the curve order: normalise a high-s signature (s → n − s, flipping v) before you send it, or it is refused. The scheme byte is digestMode << 4 | 1: its high nibble says which digest you signed, its low nibble is the verification scheme: 1 for a single secp256k1 key, or 2 for a signing policy (0x12 Typed). A policy's proof is one entry per signing member, a 1-byte member index and its 65-byte signature, so its length is 66 × the number of entries rather than 0x41.
| Scheme byte | Digest mode | What is signed | Envelope carries the domain chain ID |
|---|---|---|---|
0x11 | Typed | The EIP-712 hash of the transaction, below | Yes |
0x01 | Opaque | keccak256 of a framed hash of the transaction bytes | No |
placeOrder, cancelOrder, replaceOrder, cancelAllOrders, cancelAllOrdersAfter, moveIsolatedMargin, internalTransfer, stake and unstake allow both modes. Everything else is Typed only: setInstructionKey, createSubAccount, setStpLevel, rotateOwnerKey, transfer, withdraw and the advanced-order commands. A signature in a mode the command doesn't allow is refused 18 (Suite not permitted); one that doesn't verify is refused -20009 (Invalid signature).
A signature over a digest ATLAS doesn't compute (a wrong type string, domain or field encoding) recovers to a key other than the signer the envelope names, so it is refused -20009 (Invalid signature). If a request you signed is refused -20009, check your digest first.
Typed (EIP-712) signing
domain = { name: "atlas", version: "1", chainId: <domain chain ID>, salt: keccak256("atlas") }
<Transaction> = Transaction_<Gapless|Increasing>[_<variants>](uint32 chainId,address authority,address signer,<Nonce> nonce,bytes2 selector,<Command> command)
encodeType = "AtlasTransaction(uint8 txType,bytes1 sigSuite,<Transaction> transaction)" ‖ every referenced type, sorted by name
structHash = hashStruct(AtlasTransaction { txType: 0, sigSuite: 0x11, transaction })
signingHash = keccak256(0x19 0x01 ‖ domainSeparator ‖ structHash)This is standard EIP-712, so any EIP-712 library or wallet (eth_signTypedData_v4) can produce it. The nonce is a struct of its own, by the slot's mode, with its bool set to true:
Nonce_Gapless(bool Gapless,uint64 gapless_nonce,uint64 expires_at)
Nonce_Increasing(bool Increasing,uint64 time_stamp_nonce)A choice whose options carry fields signs as the struct of the option chosen, named after the type and the option (MarketId_Perp), with a bool named after the option set to true first: a market is MarketId_Spot(bool Spot,uint32 value) or MarketId_Perp(bool Perp,uint32 value), and a limit order's kind is OrderKind_Limit(bool Limit,int64 price,bool postOnly). A struct that holds one is named after the options it holds, joined by _, and so is the transaction struct: a perp limit cross order signs Transaction_Gapless_Perp_Limit_Cross over PlaceOrder_Perp_Limit_Cross.
Each command's type string is published with the gapless form. For an increasing nonce, replace Transaction_Gapless with Transaction_Increasing, Nonce_Gapless nonce with Nonce_Increasing nonce and the Nonce_Gapless(…) definition with Nonce_Increasing(bool Increasing,uint64 time_stamp_nonce); it sorts in the same place. For example:
AtlasTransaction(uint8 txType,bytes1 sigSuite,Transaction_Gapless_Perp transaction)CancelAllOrders_Perp(address account,bytes16 clientOrderId,MarketId_Perp marketId)MarketId_Perp(bool Perp,uint32 value)Nonce_Gapless(bool Gapless,uint64 gapless_nonce,uint64 expires_at)Transaction_Gapless_Perp(uint32 chainId,address authority,address signer,Nonce_Gapless nonce,bytes2 selector,CancelAllOrders_Perp command)AtlasTransaction(uint8 txType,bytes1 sigSuite,Transaction_Gapless_Bind transaction)BuilderFeeCap(int64 perpBps,int64 spotBps)KeyChange_Bind(bool Bind,uint8 scope,BuilderFeeCap builderFeeCap,uint8 nonceMode,Statement[] statements)Nonce_Gapless(bool Gapless,uint64 gapless_nonce,uint64 expires_at)SetInstructionKey_Bind(address account,address instructionKey,KeyChange_Bind change)Statement(string label,string value)Transaction_Gapless_Bind(uint32 chainId,address authority,address signer,Nonce_Gapless nonce,bytes2 selector,SetInstructionKey_Bind command)A command whose type depends on its value has one string per form: placeOrder by market (spot or perp), orderType (Limit or Market) and margin mode (Cross or Isolated), eight in all; cancelOrder and replaceOrder by market and by whether target names an orderId or a clientOrderId; cancelAllOrders and moveIsolatedMargin by market; setInstructionKey by bind or remove. Every command's type string is on Trading: Typed type strings.
- Quantities and prices are signed as integer mantissas: quantities at scale 8, prices at scale 10, amounts (transfers, isolated margin, stake) at scale 12, Builder Fee rates and caps in bps at scale 8.
"100.998046875"as a price signs as1009980468750. The request's decimal is parsed exactly: a digit past the scale is refused, never rounded. - Enums are
uint8:scopeINSTRUCTION_KEY_SCOPE_REDUCE_ONLY2,INSTRUCTION_KEY_SCOPE_FULL3;nonceModeGAPLESS0,INCREASING1. Order enums are on Trading. - Encoding: each field fills one 32-byte word. Integers and addresses are right-aligned;
bytes2,bytes16andbytes32values are left-aligned.stringandbytesfields hash their bytes, nested structs hash as structs, and an array hashes the concatenated hashes of its elements (Statement[]with no lines iskeccak256("")). - Optional fields sign a presence flag before the value, such as
hasBuilderFeeandbuilderFee; an absent value signs as zero. selectoris the command's 2-byte selector, the same as in the envelope, andsigSuiteis0x11.- Field order in the type strings is what is signed. JSON property order is not.
Opaque signing
An Opaque signature covers an EIP-191 frame and the hash of the transaction bytes:
keccak256( 0x19 0x00 ‖ 0x660419a32100a247f5a90410a7d8df8678052e27 ‖ 0x00 ‖ 0x01 ‖ keccak256("atlas") ‖ keccak256(transaction bytes) )The 20 bytes after 0x19 0x00 are the last 20 bytes of keccak256("atlas/transaction/v1"). After them come the envelope type 0x00, the scheme byte 0x01, the transaction salt, then the keccak256 of the transaction bytes exactly as the envelope lays them out, from chainId to the end of the command. The transaction's own chainId binds an Opaque signature to one deployment.
Transaction ID
The signing digest (the Typed or Opaque hash) is the transaction's identity, its txId: 0x + 64 lowercase hex. Write results carry it as txId, and so do the orders, fills and history rows it produced. atlas.getTransactionReceipt answers committed once it applied, and atlas.getTransactionByHash returns what was signed. A txId applies at most once: resending the same signed bytes after the first applied is refused by the nonce check, 290 (Nonce not next) on a gapless slot or 21 (Nonce stale) on an increasing one, instead of placing a second order. The one exception is a gapless key that is removed and bound again, or an owner key rotated back, while its old requests are unexpired: see Gapless.
Every write waits for its outcome: applied, refused or unknown. How to handle each is on Errors: Results, refusals and unknown outcomes.
Nonce
nonce, the transaction nonce, is your replay protection. It belongs to a key slot: one key on one account. The slot's mode decides the nonce's form, and a nonce of the other form is refused 20 (Nonce malformed).
| Slot | Where | Mode |
|---|---|---|
| Owner slot | The wallet's Main, for every command the owner key signs, whichever account it names | Always GAPLESS |
| Instruction slot | Each account an instruction key is bound to | The nonceMode its bind named: GAPLESS or INCREASING |
A key bound to two accounts has two slots, and the owner key bound to Main as an instruction key has two slots there: its owner slot and its instruction slot. No two slots share nonces. A slot's mode is fixed until its key is removed and bound again.
atlas.getKeys returns ownerKeyNonce, the owner slot's last accepted value, and each gapless binding's lastGaplessNonce. Both are eventually consistent.
Gapless
For a person or a cold signer. Each request carries gapless_nonce, exactly one above the last one the slot accepted, and expires_at, an expiry in Unix seconds that the signature covers.
| Rule | Refused with |
|---|---|
gapless_nonce is exactly last + 1. A new slot starts at 0, so its first request carries 1 | 290 (Nonce not next) |
expires_at is after the server's time | 22 (Nonce too old) |
expires_at is at most 14 days (1,209,600 seconds) after the server's time | 23 (Nonce too far ahead) |
atlas.getKeysshowsownerKeyNonce: "6". It is Unix second1791210612.- Your next owner command signs
gapless_nonce7withexpires_atone day ahead:1791297012. - It is refused for its margin. The counter stays at 6, so your next request signs
7again. - A request signed with
8before7has applied is refused290. Gapless is one stream: send in order.
The counter starts again at 0 when a key is bound again, and when the owner key rotates. A request signed before the reset could then match the new counter until it expires. Sign with a short expiry (a day, say) when a key may be bound again or rotated back.
Increasing
For a program that signs often, or from several writers. Each request carries a time_stamp_nonce, a u64 sent as a decimal string, because it may exceed 2^53. It packs the time you signed:
63 | 62 ──────── 18 | 17 ──── 8 | 7 ──── 2 | 1 ──── 0
0 | unix_ms | seq | reserved | channel
nonce = (unixMs << 18) | (seq << 8) | channel| Field | Bits | Meaning |
|---|---|---|
unix_ms | 45 | When you signed, in Unix milliseconds. The top bit of the u64 stays zero |
seq | 10 | A count, 0 to 1023, of the requests signed on this channel in this millisecond |
| reserved | 6 | Must be zero |
channel | 2 | A nonce channel, 0 to 3 |
A nonce channel is an independent stream inside one slot. Give each independent writer of a key its own channel, and send requests whose order matters on one channel. A channel carries no authority or priority. A writer that needs no concurrency uses channel 0.
To sign, use max((nowMs << 18) | channel, last + 256), where last is the last nonce you signed on that channel. Adding 256 bumps seq; a burst past 1,024 in one millisecond rolls into the next millisecond.
- At Unix ms
1791210612345on channel0:1791210612345 << 18=469555114762567680. - A second request in the same millisecond, same channel:
469555114762567680 + 256=469555114762567936. - A second writer on channel
3at the same moment:469555114762567683. It doesn't collide with channel0. - The 1,025th request on channel
0in that millisecond is469555114762829824, whose millisecond (nonce >> 18) is1791210612346.
The check is per slot and per channel:
| Rule | Refused with |
|---|---|
| Non-zero, with the top bit and the reserved bits zero | 20 (Nonce malformed) |
| Strictly greater than the highest nonce of this slot's channel from an applied transaction | 21 (Nonce stale) |
Its millisecond (nonce >> 18) less than 60 seconds behind the venue's clock | 22 (Nonce too old) |
| Its millisecond less than 10 seconds ahead of the venue's clock | 23 (Nonce too far ahead) |
Wait 10 seconds after binding. A new increasing slot starts every channel at the bind's stamped time plus 10 seconds, so a request timed by your own clock is refused 21 until then. setInstructionKeyApplied returns that time as stampedAtMs. Alternatively, sign ((stampedAtMs + 10000) << 18) | (1 << 8) | channel to go at once.
A refused request
A refused transaction does not consume its nonce. Its signed bytes stay admissible: a gapless request while its number is the next and it hasn't expired, an increasing one until the same slot applies a higher nonce on that channel or it falls 60 seconds behind. Treat a refused signature as live until then. If you replace it, sign the replacement with the same nonce, so only one of the two can ever apply.
After a timeout or a lost reply the outcome is unknown, not refused: resolve it as Errors describes, and resend only the identical signed bytes. Don't sign the same intent again with a new nonce while the first is open: both could apply.
Signed messages (TermsAcceptance) have no nonce: they carry their own time. The advanced-order commands use a gapless nonce of their own, one sequence per signer.
Server time
The nonce window and the gapless expiry are checked against server time, not your clock. atlas.getTime on POST /seq/rpc returns the server's current Unix time in milliseconds: use it to measure how far your clock is off, and keep the signing host's clock in sync. A time_stamp_nonce still carries the time you signed. atlas.getTime needs no signature and takes no params (leave params out, or send {}).
Errors
Every code these calls return, and what to do about each, is on Errors.