Skip to content

devisgood24/SorobanAnchor

 
 

Repository files navigation

SorobanAnchor

A Soroban smart contract SDK for Stellar anchors. Handles attestation management, SEP-6 deposit/withdrawal flows, SEP-10 JWT authentication, anchor routing, rate limiting, and transaction state tracking — all in a no_std Rust library compiled to WASM.

What it does

  • Registers and revokes attestors with SEP-10 JWT verification
  • Submits and retrieves on-chain attestations with replay attack protection
  • Normalizes SEP-6 deposit, withdrawal, and transaction status responses across anchors
  • Verifies SEP-10 EdDSA JWTs on-chain using stored Ed25519 public keys
  • Routes requests across multiple anchors by reputation, fees, and settlement time
  • Caches anchor metadata and stellar.toml capabilities with TTL-based expiry
  • Tracks transaction state transitions with full audit logging
  • Propagates request IDs and tracing spans across operations
  • Enforces rate limits and configurable retry/backoff strategies
  • Validates anchor domain endpoints and response schemas

Project structure

src/                        # Core library
  lib.rs                    # Public API surface
  contract.rs               # Soroban contract (attestations, sessions, quotes, routing)
  sep6.rs                   # SEP-6 deposit/withdrawal normalization
  sep10_jwt.rs              # SEP-10 JWT verification (EdDSA, no_std)
  domain_validator.rs       # Anchor domain/endpoint validation
  errors.rs                 # Stable error codes
  rate_limiter.rs           # Rate limiting
  response_validator.rs     # Response schema validation
  retry.rs                  # Retry with exponential backoff
  transaction_state_tracker.rs
  deterministic_hash.rs     # Canonical SHA-256 payload hashing

tests/                      # Integration and unit tests
configs/                    # Example anchor configurations (JSON + TOML)
examples/                   # Rust and shell usage examples
scripts/                    # Build, validation, and deploy scripts
docs/                       # Feature and guide documentation
test_snapshots/             # Snapshot fixtures for deterministic tests

Building

cargo build --release

For WASM output (Soroban deployment):

cargo build --release --target wasm32-unknown-unknown --no-default-features --features wasm

Testing

cargo test

CLI

# Deploy to testnet
anchorkit deploy --network testnet

# Register an attestor
anchorkit register --address GANCHOR123... --services deposits,withdrawals,kyc

# Submit an attestation
anchorkit attest --subject GUSER123... --payload-hash abc123...

# Check environment setup
anchorkit doctor

Key APIs

// SEP-6: normalize a raw anchor deposit response
let response = initiate_deposit(raw)?;

// SEP-10: verify an anchor JWT on-chain
contract.verify_sep10_token(token, issuer);

// Submit an attestation (replay-protected)
let id = contract.submit_attestation(issuer, subject, timestamp, payload_hash, sig);

// Route across anchors by lowest fee
let best = contract.route(options);

// Track transaction state
tracker.transition(tx_id, TransactionStatus::Completed);

Configuration

Anchor configs live in configs/ as JSON or TOML. Validate them with:

./scripts/validate_all.sh

Schema reference: config_schema.json

License

MIT

About

A Soroban smart contract SDK for Stellar anchors — handles SEP-6 deposits/withdrawals, SEP-10 JWT auth, on-chain attestations with replay protection, anchor routing, and transaction state tracking. Built in no_std Rust, compiled to WASM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 49.6%
  • HTML 24.1%
  • TypeScript 21.6%
  • Shell 2.0%
  • JavaScript 1.7%
  • CSS 0.6%
  • Other 0.4%