Skip to main content
Sign-In with X (SIWX) lets you authenticate with ChainStream by signing a message with your wallet on every API request — no API Key or OAuth token needed. This is designed for AI agents with on-chain wallets that have purchased a subscription via x402 payment.
SIWX replaces the API Key. Instead of passing X-API-KEY, you pass Authorization: SIWX <token> on each request. The gateway verifies the signature and checks for a valid x402 subscription in real time.

How It Works

Unlike traditional challenge/response flows, SIWX is stateless and self-contained. The client constructs and signs the message locally, then attaches it to every request.

Step-by-Step

  1. Construct an EIP-4361 message with your wallet address, domain, nonce, and expiration time
  2. Sign the message with your wallet private key
  3. Encode as SIWX token: base64(message).signature
  4. Attach to every API request: Authorization: SIWX <token>
  5. The gateway verifies the signature and checks that the wallet has an active x402 subscription
  6. If valid, the request proceeds normally (same as API Key auth)

Token Format

The message follows the EIP-4361 standard:

Required Fields

The expiration time is set by the client. You can sign a message valid for minutes, hours, or days. A longer expiration means fewer re-signs, but a shorter one is more secure.

Supported Chains

Prerequisites

SIWX authentication requires an active x402 subscription linked to the wallet address. Without a subscription, the gateway rejects the request with an error. To get a subscription:
See x402 Payment for details.

Usage Examples

cURL

SDK

CLI

The CLI uses SIWX automatically when you log in with a wallet:

SIWX vs API Key

Security Considerations

  • Stateless: No server-side session. Each request is independently verified.
  • Expiration: The client controls token lifetime via the Expiration Time field. Expired tokens are rejected.
  • Domain binding: The message includes api.chainstream.io as the domain. Signatures for other domains are rejected.
  • No private key exposure: The wallet only signs a plaintext message — the private key is never transmitted.
  • Subscription check: Even with a valid signature, the request is rejected if the wallet has no active x402 subscription.