Smart Contract

Budget-controlled payments with on-chain verification

This contract powers X402DIRECT payments by enforcing budgets, approvals, and limits in a transparent and auditable way.

Summary: What this smart contract does

This is a budget-controlled payment system for cryptocurrency. Think of it like a company expense account or a digital allowance system. It lets you create spending budgets with limits and optionally authorize other wallets to spend from those budgets on your behalf.

Core purpose

Set budgets with limits, approve other wallets to spend, and automatically track spending so limits are never exceeded.

Create spending budgets

  • Set a budget with its own spending limit.
  • Budgets can reset hourly, daily, weekly, monthly, or never.

Delegate spending authority

Authorize other wallets to make payments from your budgets. Useful for teams, families, or automated services.

Control which tokens are used

Choose which stablecoins each budget can use. Only pre-approved tokens can be enabled.

Recipient restrictions (optional)

Restrict who can receive payments: a global verified list, your own allowlist, or anyone.

Proof typeMeaning
0 (All)No restriction
1 (Verified)Must be on global verified list
2 (Custom)Must be on the payor’s custom allowlist
3 (Verified or Custom)Budget allows either verified or custom

Per-transaction limits

Set a maximum amount per payment as an extra safety measure.

How payments work

  1. The payer or an authorized wallet initiates a payment.
  2. The contract checks the budget, limits, and recipient rules.
  3. A flat fee and percentage fee are applied (payer or recipient can cover them).
  4. Funds are transferred to the recipient.
  5. The budget's spent amount is updated automatically.

Safety features

  • Duplicate payment protection: direct calls block nonce reuse within 24 hours.
  • Signed payments use a payee-generated nonce unique per payee + payor.
  • Budget limits: spending stops when limits are reached.

Privacy

Transaction logs show a coded reference number rather than clear details of who paid whom or how much.

Fees

Use of the smart contract costs a flat fee per payment plus a percentage fee. You can choose whether the payer or the recipient absorbs these fees.

Referrals can share a portion of the fee with a referrer (up to 30% of the fee) for up to two years from referral time. The remaining fee is routed to the fee wallet.

Who controls what

Payor
Create budgets, authorize wallets, enable tokens, set limits.
Authorized wallets
Spend from budgets you granted access to.

In plain English

This is like giving someone a prepaid debit card with a refill schedule, spending rules, approved recipients, and automatic tracking so you never exceed your limit.

Explore the contracts

View live contract addresses on their blockchain explorers.