Smart Contracts

PayGate is powered by three Soroban smart contracts deployed on the Stellar network. All contracts operate trustlessly — they cannot be altered or paused by the PayGate team after deployment.

Deployed Contracts (Testnet)

ContractContract ID (Testnet)
Receipt VerifierCBUGM2OM6Z3XSRTVN3Y4LI6SH3CXW2GUKNQL2FQKNERABFCNDT7DXRGI
PayGate RouterCDHAMAEXMNLHUDBF5EKF3OYYPHIRUOWWSSW6ML4ANDDRESHGTVGMRO3L
PayGate ReputationCDEXJVXD4AAT73DDSEOEOCFZZFSYBKZAJFQ37EYFG3TS57F7E25HHHA6

PayGate Router

The Router contract is the economic backbone of the protocol. When an AI agent pays for an API call, the USDC flows through this contract which performs an atomic on-chain split:

  • 90% is transferred directly to the API Developer's Stellar wallet address.
  • 10% goes to the Protocol Treasury wallet for ongoing protocol development.

The split happens in a single Soroban invocation using the Stellar Asset Contract (SAC) token client, guaranteeing atomicity — either both transfers succeed, or neither does.

PayGate Reputation

The Reputation contract is an on-chain staking system. To list an API in the public marketplace, a developer must call the stake_api(developer_address, api_id, amount) function and lock up 1 USDC.

This creates a financial deterrent against spam and malicious APIs. The contract emits the following Soroban events:

  • staked — emitted when a developer stakes USDC to list an API.
  • voted — emitted when a user votes on an API's quality.
  • unstaked — emitted when a developer withdraws their stake.

These events are picked up in real-time by the PayGate backend Soroban event indexer, keeping the marketplace perfectly in sync with on-chain state.

Receipt Verifier

Every successful payment verification is logged immutably to this contract. It provides an auditable, tamper-proof proof-of-payment trail that any developer or user can verify independently on the Stellar network.

Local Development

To run the contracts locally or run the test suite:

# Clone the repository
git clone https://github.com/sauravs296/PayGate.git
cd PayGate/contracts

# Run all Soroban unit tests
cargo test --workspace

# Build the contracts to WASM
cargo build --target wasm32-unknown-unknown --release