Skip to main content
This guide walks through building a P2P payment application on Stable. The app handles the full payment lifecycle: the sender transfers USDT0 directly, the receiver detects the incoming payment in real time, and both can query their own transaction history. Same architecture as any wallet or payment interface, whether a mobile app, web checkout, or backend service. No middleware, no intermediary. For the conceptual overview, see P2P payments. To skip the ABI work and reach a working transfer in a few lines, use the Stable SDK.

What you’ll build

Five scripts forming a minimal payment app:
  • wallet.ts — create or restore a wallet.
  • getBalance.ts — query the current USDT0 balance.
  • send.ts — send USDT0 to another address.
  • receive.ts — watch for incoming payments in real time.
  • history.ts — query past Transfer events for an address.

Demo

Prerequisites

  • Node.js 20 or later.
  • A private key with testnet USDT0 (see Quick start to fund a wallet).

Project setup

Create config.ts shared by every script:

1. Create or restore a wallet

A wallet is a key pair derived from a seed phrase. Generate one for a new user and return the phrase so they can back it up. A returning user restores their wallet from the same phrase.

2. Check the balance

USDT0 is the native asset on Stable, so balance queries work exactly like ETH on Ethereum. Native balance is 18 decimals, use formatEther for display.

3. Send a payment

The sender signs and submits a transfer directly. On Stable, USDT0 is the native asset, so a simple value transfer is the cheapest path (21,000 gas). This is the same code path as “Send” in any payment app.

4. Receive payments in real time

The receiver listens for incoming Transfer events. This is equivalent to push notifications in a traditional payment app. On Stable, single-slot finality means the receiver sees a payment almost instantly.
Native transfers (value transfers) also emit a Transfer event on the USDT0 ERC-20 contract because USDT0 is both the native asset and an ERC-20 token on Stable. A single event listener covers both transfer methods.

5. Query transaction history

Query past Transfer events to build a transaction history view, like a bank statement or transaction list in any payment app.
Scanning wide block ranges (millions of blocks) can time out and exceed RPC rate limits. For production, use the Stablescan Etherscan-compatible API for paginated history queries — every transaction is already indexed.

Subscribe and collect

Pull-based recurring subscriptions with EIP-7702 delegation.

Paying with invoice

Settle invoices with ERC-3009 and deterministic nonces.

Send your first USDT0

Reference the basic native vs. ERC-20 transfer flow.
Last modified on May 11, 2026