Core concepts

The five objects you will use, and how they fit together.

Signer

A signer is a key that can authorize actions. Two kinds exist:

Kind Where the key lives Used for
secp256r1 In the user's passkey (Secure Enclave, platform authenticator). The SDK only ever sees the public key. People. This is the default.
secp256k1 A normal Ethereum key held by your own process. Servers and automation.

A SignerAggregate always has an id, a preferredChain, and optionally the account it controls. Passkey signers also carry the publicKey (x, y) and the credential id.

Account

An account is a smart contract wallet owned by a signer. It has an id (stable, chain-independent) and one contract address per chain. An account can exist before it is deployed on a given chain; reading account.address on a chain where it is not deployed throws.

Chain

You pick one chain when you create the client (chain.id). Everything the SDK reads or signs is for that chain. To work on another chain, create a second client. Supported chains are set by your deployment; Base is the default for trading.

Namespace

A namespace separates tenants that share one backend. If you run a single app, leave the default (main). The SDK sends it as the X-Namespace-Slug header on every call.

Quote

Trading, borrowing and repaying all follow one pattern:

  1. Prepare a quote. The server prices it and creates a pending record. You get a quote object with readable fields.
  2. Show the numbers to the user.
  3. Execute. The SDK builds the transaction, asks the signer to sign it, and submits it.

Quotes can be rebuilt from their id with TradeQuoteClient.fromPurchaseId, fromSaleId, fromOrderId and fromSellOrderId, so a quote survives a page reload. A quote whose order is already completed refuses to execute again.

Amounts

Amounts go in as { unit: 'human' | 'raw', value }. human is a decimal string like '10.5'; raw is a bigint in the token's smallest unit. Results always include both: amount.units.human and amount.units.raw. Use raw for arithmetic and human for display.

How the pieces connect

DattEx (client)
 ├─ signers   create / get / authenticate      → SignerClient
 └─ accounts  create                           → AccountClient
                ├─ prepareDeposit              → { typedData, submit }
                ├─ prepareTradeQuote           → TradeQuoteClient.execute()
                └─ prepareBorrowQuote          → BorrowQuoteClient.execute()