Consumer App Integration

Build a consumer-facing app like DopePay — users sign in with their wallet, send/receive money, deposit funds, and manage settings. Uses sy_auth_* (wallet auth) for user actions and sy_secret_* on your backend.

User Onboarding

1. User connects wallet (MetaMask, Phantom, etc.)

POST /v2/auth/challenge                              (no auth)
  { "wallet": "0xALICE", "chainType": "evm" }
  → { challenge: "Sign this message...", nonce: "abc" }

2. User signs the challenge in their wallet

POST /v2/auth/verify                                 (no auth)
  { "wallet": "0xALICE", "chainType": "evm",
    "signature": "0x...", "nonce": "abc" }
  → { token: "sy_auth_xxx", accountId: "acc_alice", isNewAccount: true }

3. Set username
PATCH /v2/accounts/acc_alice/settings                (sy_auth_*)
  { "username": "alice" }
  → { paymentAddress: "alice@stableyard" }
Account auto-created with defaults: settlement on Base, USDC, to wallet.

Send Money (P2P Transfer)

POST /v2/sessions                                    (sy_auth_*)
  { "type": "transfer", "amount": 10000000,
    "destination": "bob@stableyard", "sourceChain": "polygon" }
  → { id: "ses_transfer", deposit: { address: "0xDEPOSIT" },
      route: { sourceChain: "polygon", destChain: "base", estimatedSeconds: 8 } }

→ Alice sends USDC to deposit address
→ POST /v2/sessions/:id/submit-tx { txHash, chain }
→ Bob receives on his settlement chain (3-15s)
→ On-chain: Alice → Stableyard, Stableyard → Bob (privacy)
POST /v2/sessions                                    (sy_auth_*)
  { "amount": 25000000, "destination": "alice@stableyard" }
  → { checkoutUrl: "https://pay.stableyard.fi/ses_request" }

→ Alice shares the link with anyone
→ Payer opens → standard checkout flow
→ Alice receives on her settlement chain

Deposit Funds

POST /v2/deposits/addresses                          (sy_secret_*)
  { "account": "alice@stableyard", "chain": "polygon" }
  → { address: "0xALICE_DEPOSIT", chain: "polygon", chainId: 137 }

→ Show address in "Add Funds" screen
→ Anyone sends USDC/USDT to address

POST /v2/deposits/settle                             (sy_secret_*)
  { "accountId": "acc_alice", "chainId": 137 }
  → Auto-detects token, creates deposit session

View History

GET /v2/sessions                                     (sy_auth_*)
  → All sessions where user is destination (across all partners)

GET /v2/accounts/acc_alice/ledger                    (sy_auth_*)
  → Credits and debits with descriptions

Manage Settings

# Change settlement chain
PATCH /v2/accounts/acc_alice/settings                (sy_auth_*)
  { "settlement": { "crypto": { "chain": 103, "token": "USDC" } } }

# Check portfolio across chains
GET /v2/network/portfolio?address=0xALICE            (no auth)
  → Balances on every chain