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/authto request authorization entries, POST/sep45/authto 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
- The Client requests a unique challenge from the Server
- The Client verifies and signs the challenge
- The Client submits the signed challenge to the Server
- The Server verifies the challenge and responds with a JWT session token
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 yourdev.env file.
Required Configuration (If Enabled)
Optional Configuration
Configure stellar.toml
Update yourstellar.toml file to advertise SEP-45 support. Wallets discover your authentication endpoint through this file.
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 entriesPOST <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.