diff --git a/api-reference/endpoints.mdx b/api-reference/endpoints.mdx index 4c3c1fa..2f775b5 100644 --- a/api-reference/endpoints.mdx +++ b/api-reference/endpoints.mdx @@ -13,12 +13,11 @@ All requests require an API key: Authorization: Bearer wraith_live_abc123 ``` -Optional BYOM headers: - -``` -X-AI-Provider: openai -X-AI-Key: sk-... -``` +| Header | Type | Required | Description | +|---|---|---|---| +| `Authorization` | `string` | Yes | Bearer token with your platform API key. Format: `Bearer wraith_live_`. Example: `Bearer wraith_live_abc123`. | +| `X-AI-Provider` | `"gemini" \| "openai" \| "claude"` | No | AI provider for bring-your-own-model requests. See [`WraithConfig.ai`](/api-reference/types#wraithconfig). | +| `X-AI-Key` | `string` | No | API key for the provider named in `X-AI-Provider`. Example: `sk-...` for OpenAI. | --- @@ -32,29 +31,27 @@ POST /agent/create Create a new agent with a `.wraith` name. -**Request:** +**Request body:** ```typescript no-check { - name: string; // "alice" (becomes alice.wraith) - chain: string; // "horizen" | "stellar" | "ethereum" | ... - wallet: string; // owner wallet address - signature: string; // EIP-191 or ed25519 signature - message?: string; // signed message (for verification) + name: string; + chain: string | string[]; + wallet: string; + signature: string; + message?: string; } ``` -**Response:** +| Field | Type | Required | Description | +|---|---|---|---| +| `name` | `string` | Yes | Local part of the `.wraith` name (without the suffix). Constraints: 3–32 characters; lowercase alphanumeric and hyphens only; no leading or trailing hyphens. Example: `"alice"` registers `alice.wraith`. | +| `chain` | [`Chain`](/api-reference/types#chain) \| [`Chain[]`](/api-reference/types#chain) | Yes | Target chain or chains for the agent. Pass a single value, an array, or `Chain.All` for every supported chain. Example: `"horizen"` or `["horizen", "stellar"]`. | +| `wallet` | `string` | Yes | Owner wallet address that signs the creation request. EVM: `0x`-prefixed 20-byte address. Stellar: `G...` StrKey. Example: `"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"`. | +| `signature` | `string` | Yes | Wallet signature over `message` proving ownership. EVM: 65-byte EIP-191 hex string (`0x...`). Stellar: 64-byte ed25519 signature (hex). | +| `message` | `string` | No | Exact UTF-8 string that was signed. Required when the server must recover the signer from `signature`. Example: `"Sign to create Wraith agent"`. | -```typescript -{ - id: string; // UUID - name: string; // "alice" - chain: string; // "horizen" - address: string; // agent's on-chain address - metaAddress: string; // stealth meta-address -} -``` +**Response:** [`AgentInfo`](/api-reference/types#agentinfo) ### List Agents @@ -64,7 +61,7 @@ GET /agents Returns all agents for the authenticated API key. -**Response:** `AgentInfo[]` +**Response:** [`AgentInfo[]`](/api-reference/types#agentinfo) ### Get Agent by ID @@ -72,7 +69,13 @@ Returns all agents for the authenticated API key. GET /agent/:id ``` -**Response:** `AgentInfo` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. Example: `"550e8400-e29b-41d4-a716-446655440000"`. | + +**Response:** [`AgentInfo`](/api-reference/types#agentinfo) ### Get Agent by Name @@ -82,7 +85,13 @@ GET /agent/info/:name Look up an agent by `.wraith` name. -**Response:** `AgentInfo` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `name` | `string` | Local part of the `.wraith` name (without `.wraith`). Same constraints as create `name`. Example: `"alice"`. | + +**Response:** [`AgentInfo`](/api-reference/types#agentinfo) ### Get Agent by Wallet @@ -92,7 +101,13 @@ GET /agent/wallet/:address Look up an agent by owner wallet address. -**Response:** `AgentInfo` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `address` | `string` | Owner wallet address used at agent creation. Example: `"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"`. | + +**Response:** [`AgentInfo`](/api-reference/types#agentinfo) ### Get Agent Status @@ -102,6 +117,12 @@ GET /agent/:id/status Returns balance, pending invoices, and other stats. +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + **Response:** ```typescript @@ -115,6 +136,15 @@ Returns balance, pending invoices, and other stats. } ``` +| Field | Type | Description | +|---|---|---| +| `balance` | `string` | Native asset balance on the agent's primary chain as a decimal string. Example: `"1.5"`. | +| `tokens` | `Record` | Token symbol to balance map for the primary chain. Values are decimal strings. Example: `{ "USDC": "50.0", "ZEN": "100.0" }`. | +| `pendingInvoices` | `number` | Count of invoices with `status: "pending"`. Non-negative integer. | +| `address` | `string` | Agent on-chain address on the primary chain. Format depends on chain (EVM `0x...`, Stellar `G...`). | +| `metaAddress` | `string` | Stealth meta-address on the primary chain. Example: `"st:eth:0x..."` or `"st:xlm:..."`. | +| `chain` | [`Chain`](/api-reference/types#chain) | Primary chain identifier for this status snapshot. Example: `"horizen"`. | + ### Export Private Key ``` @@ -123,23 +153,38 @@ POST /agent/:id/export Export the agent's private key. Requires a fresh wallet signature. -**Request:** +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + +**Request body:** ```typescript { - signature: string; // fresh signature from owner wallet - message: string; // signed message + signature: string; + message: string; } ``` +| Field | Type | Required | Description | +|---|---|---|---| +| `signature` | `string` | Yes | Fresh wallet signature from the owner over `message`. Same format rules as create `signature`. | +| `message` | `string` | Yes | Exact signed UTF-8 string. Must include the agent ID so the server can bind the request. Example: `"Export private key for agent 550e8400-e29b-41d4-a716-446655440000"`. | + **Response:** ```typescript { - secret: string; // "0x..." — the agent's private key + secret: string; } ``` +| Field | Type | Description | +|---|---|---| +| `secret` | `string` | Agent private key for the primary chain. EVM: 32-byte hex (`0x...`). Stellar: 32-byte seed hex. | + --- ## Chat @@ -152,32 +197,27 @@ POST /agent/:id/chat Send a natural language message to the AI agent. -**Request:** +**Path parameters:** -```typescript no-check -{ - message: string; - conversationId?: string; // continue existing conversation -} -``` +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | -**Response:** +**Request body:** ```typescript no-check { - response: string; // agent's text reply - toolCalls?: ToolCall[]; // tools the agent executed - conversationId: string; // conversation ID for continuity + message: string; + conversationId?: string; } ``` -```typescript -interface ToolCall { - name: string; // "send_payment", "scan_payments", etc. - status: string; // "success" or "error" - detail?: string; // JSON string with tool result -} -``` +| Field | Type | Required | Description | +|---|---|---|---| +| `message` | `string` | Natural language input to the agent. Non-empty UTF-8 string. Example: `"send 0.1 ETH to bob.wraith"`. | +| `conversationId` | `string` | No | UUID of an existing conversation to continue. Omit to start a new conversation. Example: `"660e8400-e29b-41d4-a716-446655440001"`. | + +**Response:** [`ChatResponse`](/api-reference/types#chatresponse) --- @@ -189,16 +229,13 @@ interface ToolCall { GET /agent/:id/conversations ``` -**Response:** `Conversation[]` +**Path parameters:** -```typescript -interface Conversation { - id: string; - title: string; - createdAt: string; - updatedAt: string; -} -``` +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + +**Response:** [`Conversation[]`](/api-reference/types#conversation) ### Create Conversation @@ -206,7 +243,13 @@ interface Conversation { POST /agent/:id/conversations ``` -**Response:** `Conversation` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + +**Response:** [`Conversation`](/api-reference/types#conversation) ### Get Messages @@ -214,6 +257,13 @@ POST /agent/:id/conversations GET /agent/:id/conversations/:convId/messages ``` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | +| `convId` | `string` | Conversation UUID. | + **Response:** ```typescript @@ -224,12 +274,27 @@ Array<{ }> ``` +| Field | Type | Description | +|---|---|---| +| `role` | `"user" \| "agent" \| "tool" \| "system"` | Message author role. `user` = client input; `agent` = model reply; `tool` = tool execution output; `system` = internal prompt context. | +| `text` | `string` | Message body as UTF-8 text. | +| `createdAt` | `string` | ISO 8601 timestamp when the message was stored. Example: `"2026-06-28T12:00:00.000Z"`. | + ### Delete Conversation ``` DELETE /agent/:id/conversations/:convId ``` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | +| `convId` | `string` | Conversation UUID to delete along with its messages. | + +**Response:** `204 No Content` on success. + --- ## Invoices @@ -240,21 +305,13 @@ DELETE /agent/:id/conversations/:convId GET /invoice/:id ``` -**Response:** +**Path parameters:** -```typescript -{ - id: string; - agentName: string; - amount: string; - asset: string; - memo: string; - status: "pending" | "paid"; - txHash: string | null; - paymentLink: string; - createdAt: string; -} -``` +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Invoice UUID. | + +**Response:** [`Invoice`](/api-reference/types#invoice) ### Mark Invoice Paid @@ -262,7 +319,15 @@ GET /invoice/:id POST /invoice/:id/paid ``` -Idempotent — calling multiple times doesn't create duplicate notifications. +Mark an invoice as paid after an on-chain payment is detected. Idempotent — repeated calls do not create duplicate notifications. + +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Invoice UUID. | + +**Response:** [`Invoice`](/api-reference/types#invoice) with `status: "paid"`. --- @@ -274,6 +339,12 @@ Idempotent — calling multiple times doesn't create duplicate notifications. GET /agent/:id/notifications ``` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + **Response:** ```typescript no-check @@ -283,16 +354,10 @@ GET /agent/:id/notifications } ``` -```typescript -interface Notification { - id: number; - type: string; - title: string; - body: string; - read: boolean; - createdAt: string; -} -``` +| Field | Type | Description | +|---|---|---| +| `notifications` | [`Notification[]`](/api-reference/types#notification) | Notifications for the agent, newest first. | +| `unreadCount` | `number` | Count of notifications where `read` is `false`. Non-negative integer. | ### Mark All Read @@ -300,12 +365,32 @@ interface Notification { POST /agent/:id/notifications/read ``` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + +Sets `read: true` on all notifications for the agent. + +**Response:** `200 OK` with empty body. + ### Clear All ``` DELETE /agent/:id/notifications ``` +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID. | + +Deletes all notifications for the agent. + +**Response:** `204 No Content` on success. + --- ## TEE @@ -324,6 +409,10 @@ GET /health } ``` +| Field | Type | Description | +|---|---|---| +| `status` | `"ok"` | Server liveness indicator. Always `"ok"` when the process is running. | + ### TEE Info ``` @@ -332,6 +421,20 @@ GET /tee/info Returns TEE environment information. +**Response:** + +```typescript +{ + provider: string; + environment: string; +} +``` + +| Field | Type | Description | +|---|---|---| +| `provider` | `string` | TEE hosting provider identifier. Example: `"phala"`. | +| `environment` | `string` | Runtime environment label reported by the enclave. Example: `"tdx"`. | + ### Remote Attestation ``` @@ -340,6 +443,28 @@ GET /tee/attest/:agentId Returns cryptographic proof that the TEE is running authentic code and the agent's keys were derived correctly. +**Path parameters:** + +| Parameter | Type | Description | +|---|---|---| +| `agentId` | `string` | Agent UUID whose key derivation path is included in the attestation quote. | + +**Response:** + +```typescript +{ + quote: string; + agentId: string; + chain: string; +} +``` + +| Field | Type | Description | +|---|---|---| +| `quote` | `string` | Base64-encoded remote attestation quote from the TEE hardware. | +| `agentId` | `string` | Agent UUID bound to this attestation. | +| `chain` | [`Chain`](/api-reference/types#chain) | Chain identifier used in the key derivation path (`wraith/agent/{agentId}/{chain}`). | + --- ## Error Responses @@ -353,6 +478,11 @@ All errors return JSON with a `message` field: } ``` +| Field | Type | Description | +|---|---|---| +| `message` | `string` | Human-readable error description. | +| `statusCode` | `number` | HTTP status code echoed in the response body. Matches the response status line. | + | Status Code | Meaning | |---|---| | 400 | Bad request (missing params, invalid signature) | diff --git a/api-reference/types.mdx b/api-reference/types.mdx index 827e1f5..2762eff 100644 --- a/api-reference/types.mdx +++ b/api-reference/types.mdx @@ -29,6 +29,8 @@ import type { ### `Chain` +Supported chain identifiers. Use the enum instead of raw strings. + ```typescript enum Chain { Horizen = "horizen", @@ -42,8 +44,21 @@ enum Chain { } ``` +| Value | Description | +|---|---| +| `Chain.Horizen` | Horizen EVM testnet/mainnet. Native asset: ETH/ZEN depending on deployment. | +| `Chain.Ethereum` | Ethereum mainnet or configured EVM network with `chainId: 1`. | +| `Chain.Polygon` | Polygon PoS network. | +| `Chain.Base` | Base L2 network. | +| `Chain.Stellar` | Stellar network (classic + Soroban). Addresses use `G...` StrKey format. | +| `Chain.Solana` | Solana cluster (devnet/testnet/mainnet-beta). Addresses use base58 public keys. | +| `Chain.CKB` | Nervos CKB network. Uses Cell-based UTXO model. | +| `Chain.All` | Expand to every chain the platform currently supports at agent creation. | + ### `WraithConfig` +Configuration for the [`Wraith`](/sdk/agent-client) client constructor. + ```typescript interface WraithConfig { apiKey: string; @@ -55,8 +70,18 @@ interface WraithConfig { } ``` +| Field | Type | Required | Description | +|---|---|---|---| +| `apiKey` | `string` | Yes | Wraith platform API key. Format: `wraith_live_`. Example: `"wraith_live_abc123"`. | +| `baseUrl` | `string` | No | Override the REST API base URL. Default: `https://api.wraith.dev`. | +| `ai` | `object` | No | Bring-your-own-model configuration. When omitted, the platform uses hosted Gemini. | +| `ai.provider` | `"gemini" \| "openai" \| "claude"` | No | AI provider identifier. Must match the key in `ai.apiKey`. | +| `ai.apiKey` | `string` | No | API key for the selected AI provider. Example: `"sk-..."` for OpenAI. | + ### `AgentConfig` +Input to `wraith.createAgent()`. + ```typescript interface AgentConfig { name: string; @@ -67,8 +92,18 @@ interface AgentConfig { } ``` +| Field | Type | Required | Description | +|---|---|---|---| +| `name` | `string` | Yes | Local part of the `.wraith` name. Constraints: 3–32 characters; lowercase alphanumeric and hyphens only; no leading or trailing hyphens. Example: `"alice"`. | +| `chain` | [`Chain`](/api-reference/types#chain) \| [`Chain[]`](/api-reference/types#chain) | Yes | One chain, multiple chains, or `Chain.All`. Example: `Chain.Horizen` or `[Chain.Horizen, Chain.Stellar]`. | +| `wallet` | `string` | Yes | Owner wallet address. EVM: `0x`-prefixed. Stellar: `G...` StrKey. | +| `signature` | `string` | Yes | Wallet signature over `message`. EVM: EIP-191 hex. Stellar: ed25519 hex. | +| `message` | `string` | No | Signed UTF-8 string used for ownership verification. Example: `"Sign to create Wraith agent"`. | + ### `AgentInfo` +Agent identity returned by create and lookup endpoints. + ```typescript interface AgentInfo { id: string; @@ -79,8 +114,18 @@ interface AgentInfo { } ``` +| Field | Type | Description | +|---|---|---| +| `id` | `string` | Agent UUID assigned at creation. Example: `"550e8400-e29b-41d4-a716-446655440000"`. | +| `name` | `string` | Local part of the registered `.wraith` name (without suffix). Example: `"alice"`. | +| `chains` | [`Chain[]`](/api-reference/types#chain) | Chains the agent is deployed on. Order matches creation request. | +| `addresses` | `Record` | Per-chain agent on-chain address. Keys are [`Chain`](/api-reference/types#chain) values. | +| `metaAddresses` | `Record` | Per-chain stealth meta-address for receiving payments. Example value: `"st:eth:0x..."`. | + ### `ChatResponse` +Return type of `agent.chat()` and `POST /agent/:id/chat`. + ```typescript interface ChatResponse { response: string; @@ -89,8 +134,16 @@ interface ChatResponse { } ``` +| Field | Type | Description | +|---|---|---| +| `response` | `string` | Agent's natural language reply to the user message. | +| `toolCalls` | [`ToolCall[]`](/api-reference/types#toolcall) | Tools executed during this turn. Omitted when no tools ran. | +| `conversationId` | `string` | Conversation UUID to pass on follow-up messages. Example: `"660e8400-e29b-41d4-a716-446655440001"`. | + ### `ToolCall` +Record of a single AI tool invocation. + ```typescript interface ToolCall { name: string; @@ -99,8 +152,16 @@ interface ToolCall { } ``` +| Field | Type | Description | +|---|---|---| +| `name` | `string` | Tool identifier. One of: `send_payment`, `pay_agent`, `scan_payments`, `get_balance`, `create_invoice`, `check_invoices`, `withdraw`, `withdraw_all`, `schedule_payment`, `list_schedules`, `cancel_schedule`, `resolve_name`, `register_name`, `get_agent_info`, `fund_wallet`, `privacy_check`. | +| `status` | `"success" \| "error"` | Execution outcome for this tool call. | +| `detail` | `string` | JSON-encoded tool result or error payload. Omitted when the tool returns no structured data. | + ### `Balance` +Return type of `agent.getBalance()`. + ```typescript interface Balance { native: string; @@ -108,8 +169,15 @@ interface Balance { } ``` +| Field | Type | Description | +|---|---|---| +| `native` | `string` | Native asset balance as a decimal string. Example: `"1.5"`. | +| `tokens` | `Record` | Token symbol to balance map. Values are decimal strings. Example: `{ "USDC": "50.0" }`. | + ### `Payment` +Detected incoming stealth payment from `agent.scanPayments()`. + ```typescript interface Payment { stealthAddress: string; @@ -118,8 +186,16 @@ interface Payment { } ``` +| Field | Type | Description | +|---|---|---| +| `stealthAddress` | `string` | One-time address that received the payment. EVM: `0x...`. Stellar: `G...`. | +| `balance` | `string` | Current balance on the stealth address as a decimal string. | +| `ephemeralPubKey` | `string` | Ephemeral public key from the announcement. EVM: 33-byte compressed hex. Stellar: 32-byte hex. | + ### `Invoice` +Payment request created by the agent. + ```typescript interface Invoice { id: string; @@ -134,8 +210,22 @@ interface Invoice { } ``` +| Field | Type | Description | +|---|---|---| +| `id` | `string` | Invoice UUID. Example: `"770e8400-e29b-41d4-a716-446655440002"`. | +| `agentName` | `string` | Local part of the payee's `.wraith` name. Example: `"alice"`. | +| `amount` | `string` | Requested payment amount as a decimal string. Example: `"1.0"`. | +| `asset` | `string` | Asset symbol on the invoice chain. Example: `"ETH"`, `"USDC"`, `"XLM"`. | +| `memo` | `string` | Human-readable invoice description shown to the payer. | +| `status` | `"pending" \| "paid"` | Payment state. `txHash` is non-null when `status` is `"paid"`. | +| `txHash` | `string \| null` | On-chain transaction hash after payment. `null` while `status` is `"pending"`. | +| `paymentLink` | `string` | Shareable HTTPS URL for the payer. Example: `"https://pay.wraith.dev/invoice/770e8400-..."`. | +| `createdAt` | `string` | ISO 8601 creation timestamp. | + ### `Schedule` +Recurring stealth payment created by the agent. + ```typescript interface Schedule { id: string; @@ -148,8 +238,20 @@ interface Schedule { } ``` +| Field | Type | Description | +|---|---|---| +| `id` | `string` | Schedule UUID. | +| `recipient` | `string` | Payee `.wraith` name (local part) or stealth meta-address. Example: `"bob"` or `"st:eth:0x..."`. | +| `amount` | `string` | Payment amount per run as a decimal string. Example: `"0.1"`. | +| `asset` | `string` | Asset symbol for each scheduled payment. Example: `"ETH"`. | +| `interval` | `"daily" \| "weekly" \| "monthly"` | Recurrence cadence. | +| `status` | `"active" \| "paused" \| "cancelled"` | Schedule lifecycle state. Only `"active"` schedules execute on `nextRun`. | +| `nextRun` | `string` | ISO 8601 timestamp of the next scheduled execution. | + ### `TxResult` +On-chain transaction result from payment, withdraw, and name operations. + ```typescript interface TxResult { txHash: string; @@ -157,8 +259,15 @@ interface TxResult { } ``` +| Field | Type | Description | +|---|---|---| +| `txHash` | `string` | Transaction hash or signature on the target chain. EVM: `0x...` hex. Solana: base58 signature. | +| `txLink` | `string` | Block explorer URL for `txHash`. | + ### `PrivacyReport` +Output of the `privacy_check` agent tool. + ```typescript interface PrivacyReport { score: number; @@ -171,8 +280,19 @@ interface PrivacyReport { } ``` +| Field | Type | Description | +|---|---|---| +| `score` | `number` | Privacy score from 0 to 100. Starts at 100; deductions apply per detected issue. | +| `issues` | `array` | Detected privacy risks. Empty when no issues are found. | +| `issues[].severity` | `"info" \| "low" \| "medium" \| "high" \| "critical"` | Impact level of the issue. | +| `issues[].issue` | `string` | Short description of the detected pattern. | +| `issues[].recommendation` | `string` | Suggested action to reduce the risk. | +| `bestPractices` | `string[]` | General privacy guidelines relevant to the agent's activity. | + ### `Notification` +In-app notification for an agent. + ```typescript interface Notification { id: number; @@ -184,8 +304,19 @@ interface Notification { } ``` +| Field | Type | Description | +|---|---|---| +| `id` | `number` | Auto-increment notification ID. | +| `type` | `string` | Event category identifier. Example: `"invoice_paid"`. | +| `title` | `string` | Short notification headline. | +| `body` | `string` | Notification detail text. | +| `read` | `boolean` | Whether the notification has been marked read. | +| `createdAt` | `string` | ISO 8601 timestamp when the notification was created. | + ### `Conversation` +Chat thread between a user and an agent. + ```typescript interface Conversation { id: string; @@ -195,6 +326,13 @@ interface Conversation { } ``` +| Field | Type | Description | +|---|---|---| +| `id` | `string` | Conversation UUID. | +| `title` | `string` | Display title, typically derived from the first user message. | +| `createdAt` | `string` | ISO 8601 creation timestamp. | +| `updatedAt` | `string` | ISO 8601 timestamp of the most recent message. | + --- ## EVM Chain Types @@ -218,37 +356,67 @@ import type { type HexString = `0x${string}`; ``` +| Field | Type | Description | +|---|---|---| +| — | `` `0x${string}` `` | Lowercase hex string with `0x` prefix. Used for addresses, keys, and calldata on EVM chains. Example: `"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"`. | + ### `StealthKeys` +Full spending and viewing key material for EVM stealth addresses. + ```typescript interface StealthKeys { - spendingKey: HexString; // 32-byte private key - viewingKey: HexString; // 32-byte private key - spendingPubKey: HexString; // 33-byte compressed public key - viewingPubKey: HexString; // 33-byte compressed public key + spendingKey: HexString; + viewingKey: HexString; + spendingPubKey: HexString; + viewingPubKey: HexString; } ``` +| Field | Type | Description | +|---|---|---| +| `spendingKey` | [`HexString`](/api-reference/types#hexstring) | 32-byte secp256k1 private key. Example: `"0x..."` (64 hex chars after prefix). | +| `viewingKey` | [`HexString`](/api-reference/types#hexstring) | 32-byte secp256k1 private key for scanning. Never equals `spendingKey`. | +| `spendingPubKey` | [`HexString`](/api-reference/types#hexstring) | 33-byte compressed secp256k1 public key (`0x02` or `0x03` prefix). | +| `viewingPubKey` | [`HexString`](/api-reference/types#hexstring) | 33-byte compressed secp256k1 public key for the viewing key. | + ### `StealthMetaAddress` +Public meta-address broadcast to senders. + ```typescript interface StealthMetaAddress { - spendingPubKey: HexString; // 33-byte compressed public key - viewingPubKey: HexString; // 33-byte compressed public key + spendingPubKey: HexString; + viewingPubKey: HexString; } ``` +| Field | Type | Description | +|---|---|---| +| `spendingPubKey` | [`HexString`](/api-reference/types#hexstring) | Recipient spending public key embedded in the meta-address. | +| `viewingPubKey` | [`HexString`](/api-reference/types#hexstring) | Recipient viewing public key for ECDH during stealth address generation. | + ### `GeneratedStealthAddress` +One-time stealth address derived for a single payment. + ```typescript interface GeneratedStealthAddress { - stealthAddress: HexString; // 20-byte EVM address - ephemeralPubKey: HexString; // 33-byte compressed public key - viewTag: number; // 0-255 + stealthAddress: HexString; + ephemeralPubKey: HexString; + viewTag: number; } ``` -### `Announcement` +| Field | Type | Description | +|---|---|---| +| `stealthAddress` | [`HexString`](/api-reference/types#hexstring) | 20-byte EVM address (`0x` + 40 hex chars). | +| `ephemeralPubKey` | [`HexString`](/api-reference/types#hexstring) | 33-byte compressed ephemeral public key included in the announcement. | +| `viewTag` | `number` | 1-byte filter tag derived from the shared secret. Range: 0–255. | + +### `Announcement` (EVM) + +On-chain stealth payment announcement (ERC-5564). ```typescript interface Announcement { @@ -256,11 +424,21 @@ interface Announcement { stealthAddress: HexString; caller: HexString; ephemeralPubKey: HexString; - metadata: HexString; // first byte is view tag + metadata: HexString; } ``` -### `MatchedAnnouncement` +| Field | Type | Description | +|---|---|---| +| `schemeId` | `bigint` | Stealth address scheme identifier. Wraith EVM uses `1n`. | +| `stealthAddress` | [`HexString`](/api-reference/types#hexstring) | Target one-time address for the payment. | +| `caller` | [`HexString`](/api-reference/types#hexstring) | Sender's on-chain address that emitted the announcement. | +| `ephemeralPubKey` | [`HexString`](/api-reference/types#hexstring) | Ephemeral public key used in ECDH with the recipient viewing key. | +| `metadata` | [`HexString`](/api-reference/types#hexstring) | Opaque metadata bytes. First byte is the view tag (0–255). | + +### `MatchedAnnouncement` (EVM) + +Announcement that belongs to the recipient's viewing key. ```typescript interface MatchedAnnouncement extends Announcement { @@ -268,6 +446,11 @@ interface MatchedAnnouncement extends Announcement { } ``` +| Field | Type | Description | +|---|---|---| +| *(inherits [`Announcement` (EVM)](/api-reference/types#announcement-evm))* | | All announcement fields. | +| `stealthPrivateKey` | [`HexString`](/api-reference/types#hexstring) | Private key that controls `stealthAddress`. Derived from viewing key + ephemeral key. | + --- ## Stellar Chain Types @@ -289,42 +472,83 @@ import type { } from "@wraith-protocol/sdk/chains/stellar"; ``` -### `StealthKeys` +### `StealthKeys` (Stellar) + +Full spending and viewing key material for Stellar stealth addresses. ```typescript interface StealthKeys { - spendingKey: Uint8Array; // 32-byte seed - spendingScalar: bigint; // clamped scalar from SHA-512(seed) - viewingKey: Uint8Array; // 32-byte seed - viewingScalar: bigint; // clamped scalar - spendingPubKey: Uint8Array; // 32-byte ed25519 public key - viewingPubKey: Uint8Array; // 32-byte ed25519 public key + spendingKey: Uint8Array; + spendingScalar: bigint; + viewingKey: Uint8Array; + viewingScalar: bigint; + spendingPubKey: Uint8Array; + viewingPubKey: Uint8Array; } ``` -### `GeneratedStealthAddress` +| Field | Type | Description | +|---|---|---| +| `spendingKey` | `Uint8Array` | 32-byte ed25519 seed for the spending key. | +| `spendingScalar` | `bigint` | Clamped scalar derived from `SHA-512(spendingKey)`. Used for signing. | +| `viewingKey` | `Uint8Array` | 32-byte ed25519 seed for the viewing key. | +| `viewingScalar` | `bigint` | Clamped scalar derived from `SHA-512(viewingKey)`. | +| `spendingPubKey` | `Uint8Array` | 32-byte ed25519 public key for the spending key. | +| `viewingPubKey` | `Uint8Array` | 32-byte ed25519 public key for the viewing key. | + +### `StealthMetaAddress` (Stellar) + +```typescript +interface StealthMetaAddress { + spendingPubKey: Uint8Array; + viewingPubKey: Uint8Array; +} +``` + +| Field | Type | Description | +|---|---|---| +| `spendingPubKey` | `Uint8Array` | 32-byte ed25519 spending public key. | +| `viewingPubKey` | `Uint8Array` | 32-byte ed25519 viewing public key. | + +### `GeneratedStealthAddress` (Stellar) ```typescript interface GeneratedStealthAddress { - stealthAddress: string; // Stellar G... address - ephemeralPubKey: Uint8Array; // 32-byte ed25519 public key - viewTag: number; // 0-255 + stealthAddress: string; + ephemeralPubKey: Uint8Array; + viewTag: number; } ``` -### `Announcement` +| Field | Type | Description | +|---|---|---| +| `stealthAddress` | `string` | Stellar StrKey address (`G...`, 56 characters). | +| `ephemeralPubKey` | `Uint8Array` | 32-byte ed25519 ephemeral public key for the announcement. | +| `viewTag` | `number` | 1-byte filter tag. Range: 0–255. | + +### `Announcement` (Stellar) + +Soroban-emitted stealth payment announcement. ```typescript interface Announcement { schemeId: number; - stealthAddress: string; // G... address - caller: string; // G... address - ephemeralPubKey: string; // hex-encoded 32 bytes - metadata: string; // hex-encoded, first byte = view tag + stealthAddress: string; + caller: string; + ephemeralPubKey: string; + metadata: string; } ``` -### `MatchedAnnouncement` +| Field | Type | Description | +|---|---|---| +| `schemeId` | `number` | Stealth address scheme identifier. Wraith Stellar uses `1`. | +| `stealthAddress` | `string` | Target `G...` address for the payment. | +| `caller` | `string` | Sender's `G...` address that emitted the announcement. | +| `ephemeralPubKey` | `string` | Hex-encoded 32-byte ephemeral public key. | +| `metadata` | `string` | Hex-encoded metadata. First byte is the view tag (0–255). | + +### `MatchedAnnouncement` (Stellar) ```typescript interface MatchedAnnouncement extends Announcement { @@ -333,6 +557,12 @@ interface MatchedAnnouncement extends Announcement { } ``` +| Field | Type | Description | +|---|---|---| +| *(inherits Stellar [`Announcement`](/api-reference/types#announcement-stellar))* | | All announcement fields. | +| `stealthPrivateScalar` | `bigint` | Scalar that controls the stealth account. Used with `signWithScalar()`. | +| `stealthPubKeyBytes` | `Uint8Array` | 32-byte ed25519 public key bytes for the stealth address. | + --- ## Stellar Federation Types @@ -411,7 +641,7 @@ Internal types used by the TEE server. Documented here for developers building c interface ChainConnector { readonly chain: string; readonly nativeAsset: string; - readonly addressFormat: "evm" | "stellar" | "solana"; + readonly addressFormat: "evm" | "stellar" | "solana" | "ckb"; deriveKeys(seed: Uint8Array): Promise; sendPayment(params: SendPaymentParams): Promise; @@ -426,6 +656,22 @@ interface ChainConnector { } ``` +| Member | Type | Description | +|---|---|---| +| `chain` | [`Chain`](/api-reference/types#chain) | Chain identifier this connector handles. Example: `"horizen"`. | +| `nativeAsset` | `string` | Symbol of the chain's native asset. Example: `"ETH"`, `"XLM"`, `"SOL"`. | +| `addressFormat` | `"evm" \| "stellar" \| "solana" \| "ckb"` | Address encoding used by this connector. | +| `deriveKeys` | `function` | Derive agent address, stealth keys, and meta-address. `seed`: 32-byte TEE seed (`Uint8Array`). | +| `sendPayment` | `function` | Send a stealth payment. Params: [`SendPaymentParams`](/api-reference/types#sendpaymentparams). | +| `scanPayments` | `function` | Scan chain data for announcements matching `stealthKeys`. Returns [`DetectedPayment[]`](/api-reference/types#detectedpayment). | +| `getBalance` | `function` | Fetch native and token balances for `address`. Returns [`ChainBalance`](/api-reference/types#chainbalance). | +| `withdraw` | `function` | Withdraw funds from one stealth address. Params: [`WithdrawParams`](/api-reference/types#withdrawparams). | +| `withdrawAll` | `function` | Withdraw from every detected stealth address. Params: [`WithdrawAllParams`](/api-reference/types#withdrawallparams). Returns [`WithdrawAllResult`](/api-reference/types#withdrawallresult). | +| `registerName` | `function` | Register `name` on-chain with the connector's name registry contract. `name`: 3–32 characters; lowercase alphanumeric and hyphens only. | +| `resolveName` | `function` | Resolve `name` to a meta-address, or return `null` if unregistered. `name`: local part of a `.wraith` name. | +| `fundWallet` | `function` | Request testnet funds for `address` from a faucet. `address`: agent on-chain address in the connector's format. | +| `getExplorerUrl` | `function` | Build a block explorer URL. `type`: `"tx"` or `"address"`. `value`: transaction hash or address string. | + ### `DerivedKeys` ```typescript @@ -436,6 +682,76 @@ interface DerivedKeys { } ``` +| Field | Type | Description | +|---|---|---| +| `address` | `string` | Agent's on-chain address on this chain. Format matches `addressFormat`. | +| `stealthKeys` | [`ChainStealthKeys`](/api-reference/types#chainstealthkeys) | Chain-specific stealth key material for this agent. | +| `metaAddress` | `string` | Encoded stealth meta-address. Example: `"st:eth:0x..."` or `"st:xlm:..."`. | + +### `ChainStealthKeys` + +```typescript +interface ChainStealthKeys { + [key: string]: unknown; +} +``` + +| Field | Type | Description | +|---|---|---| +| `[key: string]` | `unknown` | Opaque key bag defined by each connector. EVM stores [`StealthKeys`](/api-reference/types#stealthkeys); Stellar stores [`StealthKeys` (Stellar)](/api-reference/types#stealthkeys-stellar). | + +### `SendPaymentParams` + +```typescript +interface SendPaymentParams { + senderAddress: string; + senderStealthKeys: ChainStealthKeys; + recipientMetaAddress: string; + amount: string; + asset?: string; +} +``` + +| Field | Type | Required | Description | +|---|---|---|---| +| `senderAddress` | `string` | Yes | Agent address that sends the payment. | +| `senderStealthKeys` | [`ChainStealthKeys`](/api-reference/types#chainstealthkeys) | Yes | Sender stealth keys for announcement signing. | +| `recipientMetaAddress` | `string` | Yes | Encoded recipient meta-address or resolved `.wraith` name target. Example: `"st:eth:0x..."`. | +| `amount` | `string` | Yes | Payment amount as a decimal string. Example: `"0.1"`. | +| `asset` | `string` | No | Token symbol. Omit for native asset. Example: `"USDC"`. | + +### `WithdrawParams` + +```typescript +interface WithdrawParams { + stealthKeys: ChainStealthKeys; + from: string; + to: string; + amount?: string; +} +``` + +| Field | Type | Required | Description | +|---|---|---|---| +| `stealthKeys` | [`ChainStealthKeys`](/api-reference/types#chainstealthkeys) | Yes | Viewing/spending keys used to derive the stealth private key for `from`. | +| `from` | `string` | Yes | Stealth address to withdraw from. | +| `to` | `string` | Yes | Destination address for withdrawn funds. | +| `amount` | `string` | No | Amount to withdraw as a decimal string. Omit to withdraw the maximum available balance minus fees. | + +### `WithdrawAllParams` + +```typescript +interface WithdrawAllParams { + stealthKeys: ChainStealthKeys; + to: string; +} +``` + +| Field | Type | Required | Description | +|---|---|---|---| +| `stealthKeys` | [`ChainStealthKeys`](/api-reference/types#chainstealthkeys) | Yes | Keys used to scan and sign withdrawals from all matched stealth addresses. | +| `to` | `string` | Yes | Single destination address that receives all withdrawn funds. | + ### `ChainBalance` ```typescript @@ -445,6 +761,11 @@ interface ChainBalance { } ``` +| Field | Type | Description | +|---|---|---| +| `native` | `string` | Native asset balance as a decimal string. | +| `tokens` | `Record` | Token symbol to balance map. Values are decimal strings. | + ### `DetectedPayment` ```typescript @@ -455,6 +776,12 @@ interface DetectedPayment { } ``` +| Field | Type | Description | +|---|---|---| +| `stealthAddress` | `string` | Stealth address with a non-zero balance. | +| `balance` | `string` | Current balance as a decimal string. | +| `ephemeralPubKey` | `string` | Ephemeral public key from the matching announcement. | + ### `WithdrawAllResult` ```typescript @@ -465,6 +792,16 @@ interface WithdrawAllResult { } ``` +| Field | Type | Description | +|---|---|---| +| `results` | `array` | Per-address withdrawal outcome. Each entry includes `address` plus either [`TxResult`](/api-reference/types#txresult) fields or `{ error: string }`. | +| `results[].address` | `string` | Stealth address that was processed. | +| `results[].txHash` | `string` | Present on successful withdrawals. Transaction hash on chain. | +| `results[].txLink` | `string` | Present on successful withdrawals. Explorer URL for `txHash`. | +| `results[].error` | `string` | Present on failed withdrawals. Error message for that address. | +| `count` | `number` | Number of stealth addresses processed. | +| `totalWithdrawn` | `string` | Sum of successfully withdrawn amounts as a decimal string. | + ### `ResolvedName` ```typescript @@ -474,3 +811,9 @@ interface ResolvedName { address?: string; } ``` + +| Field | Type | Description | +|---|---|---| +| `name` | `string` | Local part of the resolved `.wraith` name. Example: `"alice"`. | +| `metaAddress` | `string` | On-chain stealth meta-address registered for the name. | +| `address` | `string` | Optional owner or registry address, when exposed by the chain's name contract. |