Skip to content

Implement Billing Service (Deduct from Vault via Soroban) #22

@greatest0fallt1me

Description

@greatest0fallt1me

Description
Implement a billing service that: given user_id, amount_usdc, request_id, (optional) idempotency_key — checks vault balance (from vault repo or Soroban), calls Soroban vault contract deduct(amount), on success records usage_events row with stellar_tx_hash. Retry with backoff on transient Soroban errors; fail request if insufficient balance (do not deduct).

Requirements and context

  • Must use Soroban RPC client (e.g. @stellar/stellar-sdk or Soroban client)
  • Backend must be authorized deduct caller on contract
  • Amount in contract units (e.g. 7 decimals for USDC)

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/billing-service-soroban
  • Implement changes
    • Add Soroban client config; implement deduct call (sign with backend key)
    • Billing service: check balance, call deduct, persist usage event with tx hash
    • Idempotency: if usage event already exists for request_id, skip
    • Add tests (mock Soroban or testnet)
  • Test and commit
    • Run tests; document env (RPC URL, network, backend secret key)
    • Example commit message: feat: billing service deduct via Soroban

Guidelines

  • Secure key handling (env, never log)
  • Clear documentation
  • Timeframe: 96 hours
  • Project details: #

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions