Skip to main content

Overview

SEP-45 (Stellar Web Authentication for Contract Accounts) enables smart wallet applications to create authenticated sessions with Stellar anchors by proving control over a contract account (C...). Once authenticated, wallets receive a JSON Web Token (JWT) that they use in subsequent requests to the anchor’s standardized services. For the complete specification, see SEP-45: Stellar Web Authentication for Contract Accounts. The Anchor Platform implements SEP-45 with support for:
  • Challenge/Response Flow: GET /sep45/auth to request authorization entries, POST /sep45/auth to validate and receive a JWT
  • Contract Account Authentication: Support for contract accounts (C...) using Soroban authorization entries
  • Transaction Simulation: Automatic simulation of transactions to verify authorization entries
  • Multiple Home Domains: Support for multiple domains and wildcard patterns
SEP-45 vs SEP-10: SEP-45 does not replace SEP-10. SEP-45 supports contract accounts (C...), while SEP-10 supports classic accounts (G...) and muxed accounts (M...). Services wishing to support all account types should implement both SEPs.

Typical Authentication Flow

  1. The Client requests a unique challenge from the Server
  2. The Client verifies and signs the challenge
  3. The Client submits the signed challenge to the Server
  4. The Server verifies the challenge and responds with a JWT session token
An implementation of the SEP-45 contract is provided in the Anchor Platform repository. An instance of this contract is deployed at CD3LA6RKF5D2FN2R2L57MWXLBRSEWWENE74YBEFZSSGNJRJGICFGQXMX on testnet.

Enable SEP-45

SEP-45 requires integration with Stellar RPC to simulate transactions. The Anchor Platform can connect to the Stellar RPC server of your choice. You can use a public Stellar RPC provider, or you can run your own. A list of public providers can be found here. To enable SEP-45, set the following environment variables in your dev.env file.

Required Configuration (If Enabled)

  • RPC Requirement: SEP-45 requires Stellar RPC to simulate transactions. You must set STELLAR_NETWORK_TYPE=rpc and provide a valid STELLAR_NETWORK_RPC_URL.
  • Contract ID: The SEP45_WEB_AUTH_CONTRACT_ID must match the contract deployed at the address specified in your stellar.toml file’s WEB_AUTH_CONTRACT_ID field.
  • Signing Key: The SIGNING_KEY in your stellar.toml file must be the public key derived from SECRET_SEP10_SIGNING_SEED.

Optional Configuration

Multiple Home Domains: If you specify multiple home_domains (e.g., ap.stellar.org,*.sdp.stellar.org), you must also set SEP45_WEB_AUTH_DOMAIN to specify which domain hosts the authentication endpoint.

Configure stellar.toml

Update your stellar.toml file to advertise SEP-45 support. Wallets discover your authentication endpoint through this file.
These fields should match the configuration options set in the Enable SEP-45 section above. WEB_AUTH_FOR_CONTRACTS_ENDPOINT - The URL where the authentication service is running. This is the URL that clients will use to authenticate with the anchor. The endpoint must support:
  • GET <WEB_AUTH_FOR_CONTRACTS_ENDPOINT> - Request authorization entries
  • POST <WEB_AUTH_FOR_CONTRACTS_ENDPOINT> - Exchange signed authorization entries for session JWT
WEB_AUTH_CONTRACT_ID - The contract ID of the SEP-45 contract. This is the contract that will be used to construct the challenge. The contract must implement the web_auth_verify function as described in the SEP-45 specification. This should match SEP45_WEB_AUTH_CONTRACT_ID.
  • SIGNING_KEY: Must be the public key derived from SECRET_SEP10_SIGNING_SEED
  • WEB_AUTH_FOR_CONTRACTS_ENDPOINT: Use https:// in production. The path /sep45/auth is the standard SEP-45 endpoint.
  • Host Matching: The host in WEB_AUTH_FOR_CONTRACTS_ENDPOINT should match one of your SEP45_HOME_DOMAINS (or the SEP45_WEB_AUTH_DOMAIN if specified).