Skip to content

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

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 signToWhereSigned by
RetailWsHandshake (EIP-712)Open the optional trading WebSocket for an accountFirst frame on /seq/wsThe owner key or a key bound to the account. It grants no authority by itself
SignIn (EIP-712)Bind a WebSocket connection to an accountauth.signIn on /account/wsThe owner key
Login (EIP-712)Open an HTTP session for private readsauth.login on POST /account/rpcThe 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 requestsatlas.sendRawTransaction on POST /seq/tx or /seq/wsThe owner key or a bound instruction key, as each command allows
A signed message (raw bytes)Accept a new terms versionatlas.sendRawMessage on POST /seq/tx or /seq/wsThe 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
Signature format
Account identity
What a transaction signs
Transaction domain
Write transport
Replay protection

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), or 24 (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 setInstructionKey signatures; 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 authority and its signer. The server recovers the key from the signature, checks that it is the signer, that authority is the account whose authority the command exercises, and that the signer may act for it. Knowing an address proves nothing.
  • atlas.getKeys lists a wallet's owner-key nonce and every bound key with its bindings.

Who signs what

CommandSigned by
placeOrder, replaceOrderA key bound to the account. An INSTRUCTION_KEY_SCOPE_REDUCE_ONLY binding places and replaces reduce-only perp orders only
cancelOrder, cancelAllOrders, cancelAllOrdersAfterA 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, unstakeA key bound to the account with INSTRUCTION_KEY_SCOPE_FULL
setInstructionKey, createSubAccount, setStpLevel, rotateOwnerKey, transfer, withdrawThe owner key
Onboarding: the bind sent with atlas.sendWalletReadyRequest, and the message TermsAcceptanceThe owner key
setAdvanceInstructionKeyThe owner key
createTpSlOrder, updateTpSlOrder, cancelTpSlOrder, createTwapOrder, cancelTwapOrder, cancelAllTwapsThe 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.

  1. Derive your address

    Main's address is your key's Ethereum-style address. You can compute it offline before anything exists on ATLAS.

  2. Deposit to it

    Send any asset the venue lists to that address. There is no minimum and no fee. It waits there unclaimed.

  3. Read the terms in force

    atlas.getTerms returns the one Atlas Terms of Use version in force: its id, version and contentHash. Fetch the text from documentUrl and check its keccak256 before you show it.

  4. Sign one bind and send it

    With the owner key, sign a setInstructionKey bind of your instruction key whose statements accept the terms. Send it with atlas.sendWalletReadyRequest as ["enableTrading", rawTx, statements] on POST /seq/tx. The /seq/ws handshake 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:

labelvalue
Atlas Terms of Use<id>@<version> 0x<contentHash>, from atlas.getTermsRequired
BuilderA Builder ID to stamp on the wallet, 0x + 40 lowercase hexOptional
RequestenableTrading or enableBuilder: the kind of the requestOptional for enableTrading, required for enableBuilder
atlas.sendWalletReadyRequest
{
  "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 a label over 64 bytes or a value over 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_at within the gapless bounds: 1 for a wallet not yet open, or ownerKeyNonce + 1 from atlas.getKeys for 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…"]):

  • TermsAcceptance accepts a new terms version without binding a key. It has chainId, wallet, the same statements, and expiresAt in Unix seconds, which must be in the future and at most one day ahead.
  • To become a builder, send the bind with atlas.sendWalletReadyRequest and kind enableBuilder over POST /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's nonceMode (another is refused 20); 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):

Message type strings
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.

rawMessage, field by field
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                                                                  v
  • structHash: 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.

EIP-712 domain
EIP712Domain(string name,string version,uint256 chainId,bytes32 salt)
DomainnameversionchainIdsaltUsed by
Transactionatlas"1"The domain chain ID: the chain your wallet signs atkeccak256("atlas") = 0xb7d6c242d4540c764ba9e759f9bb318a9ca9c855fed6042f495d287cb9cd8d7bEvery Typed transaction to the venue
Messageatlas"1"The domain chain IDkeccak256("atlas/message") = 0x0b5873bb429980cb4a1d5c447764f2f2739fd05490b8ac751d5b3cba3e58c5d8The /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 ordersatlas"1"The domain chain IDkeccak256("atlas/oms") = 0x544f3ca127b04fe03bc2a496b90dc6fe33455b498edcf062397898bb2e1087f9TP/SL, TWAP and setAdvanceInstructionKey. See Advanced orders
Advanced-order readsatlas"1"The domain chain IDkeccak256("atlas/oms/message") = 0x9311f5904f2bc44d83812f65002538274c5401c02d43414cf8da75b9b1c91992The 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, and auth.signIn, auth.login and the signed messages sign it too. Any other is refused 246 (Atlas chain id mismatch). atlas.getVersion returns it as signing.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, as domainChainId on sign-in and login, as chain_id in 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.

ExampleCheck your domain separator
  • 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 chainId is hashed as a uint256.

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.

SequenceSign in on /account/ws
Your key
Client
ATLAS
  1. GET /account/ws · upgrade
  2. auth.challenge{…}
  3. result · challenge{…}single-use, held briefly
  4. sign EIP-712 SignInoffline: chainId, sender, challenge, scopeHash, under the message domain
  5. 65-byte signature
  6. auth.signIn{…}
  7. Checks the signature against the owner key and consumes the challenge
  8. result · signed in{…}
  9. The account stays bound to this connection until it closes
Click any message to see its payload

—

0/9

The signed message

EIP-712 SignIn
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/ws

Returns 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

auth.signIn

auth.signInWebSocket/account/ws
accountAddressAccountAddressrequired
challengestringrequired
chainIdintegerrequired
domainChainIdUint256Stringrequired
signaturestringrequired

SignInResponse

successbooleanrequired
authedAccountAddressAccountAddressrequired
ErrorWhen
-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
-32602Wrong hex length, a malformed accountAddress, chainId or domainChainId
-20003Sign-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.

  1. Get a challenge

    auth.challenge on POST /account/rpc. Over HTTP the challenge is not tied to a connection, and expires 60 seconds after it is issued.

  2. Sign Login and log in

    Sign Login with the owner key or a key bound to the account, and send it with auth.login. You get an access token (one hour) and a refresh token (the session lasts seven days).

  3. Read, refresh, log out

    Send Authorization: Bearer <accessToken> on each private read. Before expiresAt, swap the refresh token for a new pair with auth.refresh. End the session with auth.logout.

EIP-712 Login
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/rpc
accountAddressAccountAddressrequired
challengestringrequired
chainIdintegerrequired
domainChainIdUint256Stringrequired
signaturestringrequired

LoginResponse

accessTokenstringrequired
tokenTypestringrequired
expiresAtTimestampMsrequired
refreshTokenstringrequired
refreshExpiresAtTimestampMsrequired
walletAddressAccountAddressrequired
accountAddressesAccountAddress[]required
keyKindenumrequired

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/rpc

Takes 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/rpc

Takes 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/rpc

Passes 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/rpc

Takes 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.

RetailWsHandshake, the first text frame
{
  "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
account_addressAccountAddressrequired
nonceintegerrequired
ts_msintegerrequired
chain_idUint256Stringrequired
signatureSignature65required

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>":

CodeWhy
-32700The frame is not JSON
-32600A binary, non-text or oversized frame
-32602Fields don't decode (for example a missing chain_id), or a wrong purpose
-20009The signature does not verify
-10009The account is unknown: onboard over POST /seq/tx first. Otherwise retry with backoff
-10018No handshake before the 10-second timeout
-10019ts_ms outside the freshness window
-20001Rate 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.

atlas.sendRawTransaction
{ "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.

  • chainId is the Atlas chain ID: 33003. A transaction for any other is refused 246 (Atlas chain id mismatch), so a transaction signed for another deployment can never apply here.
  • authority is 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 refused 329 (Authority mismatch), and a signature made for one authority doesn't verify for another.
  • signer is 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.

BytesField
1Transaction typeAlways 0x00
1Scheme byte0x11 Typed or 0x01 Opaque. See The signature
4chainIdThe Atlas chain ID, big-endian u32: 0x000080eb
20authorityThe account whose authority the command exercises
20signerThe signing key's address
17 or 9nonceA 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 + ncommandThe command's 2-byte selector, then its fields. See Action encoding
8Domain chain IDTyped only: the EIP-712 domain chainId you signed at, big-endian u64. Absent for Opaque
1Proof length0x41: the proof's length, 65, as a VLQ. One byte for a single-key signature
65Signaturer ‖ 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:

TypeEncoding
Integers (u8, u32, u64, i64, i128)Fixed width, big-endian. Signed integers are two's complement
DecimalsThe 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
Addresses20 bytes
Ids and fixed-size bytes (clientOrderId, a transfer's 64-byte memo, statements, receiver)As they are, at their fixed size
bool1 byte: 0 or 1
A choice (side, timeInForce, marginMode, kind, target, …)A 1-byte tag, then that choice's own fields, if any
A marketA tag, 0 spot or 1 perp, then the market's number as a u32: 5 bytes. {"PERP": {"id": 1}} is 01 00000001
An optional field0, 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.

transfer, before encoding
{
  "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"
    }
  }
}
rawTx, field by field
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                                                                v

A 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:

Typed digest of this transfer
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      0x9536c8683d4a1e4ca1151d102100693d06697915acf9e6aae652bc0bdba6d62e

The 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.

rawTx
0x0011000080ebf39fd6e51aad88f6f4ce6ab8827279cfffb92266f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000001000000006b49d2006e61f39fd6e51aad88f6f4ce6ab8827279cfffb9226671d4b8e2a5c9f3b6d0e7a1c4f8b2d5e9a3c6f0b400000001000000000000000000002d79883d20006f72642d34320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080eb41c305a9f6ca3869eecc68651440647398ed38201aa7fdd0fc53430ff46ce2f7d71d165d747da37431fab5c900323c81b0aea1d3483c26f3fe3e1711bcc53f920b01

Statements 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:

FieldBytesEncoding
account20address
marketId5market: tag 0 spot or 1 perp, then a u32
clientOrderId1616 bytes
side10 buy, 1 sell
quantity8i64: quantity × 10⁸
orderType1 or 100 limit, then price (i64: price × 10¹⁰) and postOnly (0 or 1). 1 market, with nothing after it
timeInForce10 ioc, 1 gtc, 2 fok
marginMode1, 2 or 180 cross. 1 isolated, then openingMargin: 0 if absent, or 1 and an i128 (amount × 10¹²)
reduceOnly10 false, 1 true
builderFee1 or 290 if absent, or 1, appBuilderId (20 bytes) and builderFeeBps (i64: bps × 10⁸)

cancelOrder, selector 0x655f:

FieldBytesEncoding
account20address
clientOrderId1616 bytes
marketId5market
target9 or 170 and orderId (the bare sequence) as a u64, or 1 and a 16-byte clientOrderId

replaceOrder, selector 0x2b8f:

FieldBytesEncoding
account20address
marketId5market
target9 or 170 and orderId as a u64, or 1 and a 16-byte clientOrderId
clientOrderId1616 bytes
quantity8i64: quantity × 10⁸
price8i64: price × 10¹⁰
postOnly10 false, 1 true
reduceOnly10 false, 1 true

cancelAllOrders, selector 0xceb1:

FieldBytesEncoding
account20address
clientOrderId1616 bytes
marketId5market

cancelAllOrdersAfter, selector 0xb301:

FieldBytesEncoding
account20address
timeoutSeconds4u32 seconds

moveIsolatedMargin, selector 0x168e:

FieldBytesEncoding
account20address
marketId5market
direction10 add, 1 remove
amount16i128: amount × 10¹²

internalTransfer, selector 0x9bf9, and transfer, selector 0x6e61:

FieldBytesEncoding
account20address
toAccount20address
asset4u32
amount16i128: amount × 10¹²
memo6464 bytes; zero bytes when there is none

stake, selector 0x4472, and unstake, selector 0x3a04:

FieldBytesEncoding
account20address
asset4u32
amount16i128: amount × 10¹²

withdraw, selector 0xb21d:

FieldBytesEncoding
account20address
asset4u32
amount16i128: amount × 10¹²
destinationZone4u32
receiver3232 bytes; an EVM address is left-padded with zeros
memo1 + n or 2 + na VLQ count (2 bytes from 128), then up to 255 bytes

setInstructionKey, selector 0xef2b:

FieldBytesEncoding
account20address
instructionKey20address
change1 or 510 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:

FieldBytesEncoding
account20address
binding1 or 390 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:

FieldBytesEncoding
account20address
level10 account, 1 wallet

rotateOwnerKey, selector 0x186b:

FieldBytesEncoding
account20address
newOwnerKey1 or 210 for none, or 1 and the 20-byte address
newOwnerKeyProof1, or 2 + 66 per signature0 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

The advanced-order commands:

setAdvanceInstructionKey, selector 0x823f:

FieldBytesEncoding
accountAddress20address
instructionKey20address
change1 or 650 bind, then the omsDelegateKey's X and Y coordinates (32 bytes each). 1 remove, with nothing after it

createTpSlOrder, selector 0x9032:

FieldBytesEncoding
accountAddress20address
marketId5market
clOrdId1616 bytes
marginMode10 cross, 1 isolated
takeProfit, stopLoss1, 13 or 21 each0 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
entry1, 15, 23, 31 or 390 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¹²)
builderFee1 or 290 if absent, or 1, appBuilderId (20 bytes) and builderFeeBps (i64: bps × 10⁸)

updateTpSlOrder, selector 0xf9d9:

FieldBytesEncoding
accountAddress20address
target9 or 170 and parentOrderId as a u64, or 1 and the 16-byte origClOrdId
clOrdId1616 bytes
takeProfit, stopLoss1, 13 or 21 eachas in createTpSlOrder

cancelTpSlOrder, selector 0x846a:

FieldBytesEncoding
accountAddress20address
target9 or 17as in updateTpSlOrder
slot10 take profit, 1 stop loss, 2 both
clOrdId1616 bytes

createTwapOrder, selector 0x33bc:

FieldBytesEncoding
accountAddress20address
marketId5market
clOrdId1616 bytes
marginMode10 cross, 1 isolated
twap14side (u8: 0 buy, 1 sell), quantity (i64: quantity × 10⁸), durationSeconds (u32) and reduceOnly (0 or 1)
builderFee1 or 29as in createTpSlOrder

cancelTwapOrder, selector 0x84ae:

FieldBytesEncoding
accountAddress20address
target9 or 17as in updateTpSlOrder
clOrdId1616 bytes

cancelAllTwaps, selector 0x8208:

FieldBytesEncoding
accountAddress20address
clOrdId1616 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 no AtlasTransaction wrapper and no selector: for cancelAllTwaps it is Transaction(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 byteDigest modeWhat is signedEnvelope carries the domain chain ID
0x11TypedThe EIP-712 hash of the transaction, belowYes
0x01Opaquekeccak256 of a framed hash of the transaction bytesNo

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

Typed digest
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 types
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:

Typed: cancelAllOrders on a perp, gapless
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)
Typed: setInstructionKey, a bind
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 as 1009980468750. The request's decimal is parsed exactly: a digit past the scale is refused, never rounded.
  • Enums are uint8: scope INSTRUCTION_KEY_SCOPE_REDUCE_ONLY 2, INSTRUCTION_KEY_SCOPE_FULL 3; nonceMode GAPLESS 0, INCREASING 1. Order enums are on Trading.
  • Encoding: each field fills one 32-byte word. Integers and addresses are right-aligned; bytes2, bytes16 and bytes32 values are left-aligned. string and bytes fields hash their bytes, nested structs hash as structs, and an array hashes the concatenated hashes of its elements (Statement[] with no lines is keccak256("")).
  • Optional fields sign a presence flag before the value, such as hasBuilderFee and builderFee; an absent value signs as zero.
  • selector is the command's 2-byte selector, the same as in the envelope, and sigSuite is 0x11.
  • 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:

Opaque digest
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).

SlotWhereMode
Owner slotThe wallet's Main, for every command the owner key signs, whichever account it namesAlways GAPLESS
Instruction slotEach account an instruction key is bound toThe 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.

RuleRefused with
gapless_nonce is exactly last + 1. A new slot starts at 0, so its first request carries 1290 (Nonce not next)
expires_at is after the server's time22 (Nonce too old)
expires_at is at most 14 days (1,209,600 seconds) after the server's time23 (Nonce too far ahead)
ExampleOwner key, gapless
  • atlas.getKeys shows ownerKeyNonce: "6". It is Unix second 1791210612.
  • Your next owner command signs gapless_nonce 7 with expires_at one day ahead: 1791297012.
  • It is refused for its margin. The counter stays at 6, so your next request signs 7 again.
  • A request signed with 8 before 7 has applied is refused 290. 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:

time_stamp_nonce bit layout (u64)
 63 | 62 ──────── 18 | 17 ──── 8 | 7 ──── 2 | 1 ──── 0
  0 |    unix_ms     |    seq    | reserved |  channel
nonce = (unixMs << 18) | (seq << 8) | channel
FieldBitsMeaning
unix_ms45When you signed, in Unix milliseconds. The top bit of the u64 stays zero
seq10A count, 0 to 1023, of the requests signed on this channel in this millisecond
reserved6Must be zero
channel2A 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.

ExampleIncreasing nonces for one key
  • At Unix ms 1791210612345 on channel 0: 1791210612345 << 18 = 469555114762567680.
  • A second request in the same millisecond, same channel: 469555114762567680 + 256 = 469555114762567936.
  • A second writer on channel 3 at the same moment: 469555114762567683. It doesn't collide with channel 0.
  • The 1,025th request on channel 0 in that millisecond is 469555114762829824, whose millisecond (nonce >> 18) is 1791210612346.

The check is per slot and per channel:

RuleRefused with
Non-zero, with the top bit and the reserved bits zero20 (Nonce malformed)
Strictly greater than the highest nonce of this slot's channel from an applied transaction21 (Nonce stale)
Its millisecond (nonce >> 18) less than 60 seconds behind the venue's clock22 (Nonce too old)
Its millisecond less than 10 seconds ahead of the venue's clock23 (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.