Menu

Explorer & Settings

Tempo Explorer Submit Project
Back to all projects
S

Solana-X402-Payment-Protocol

by topsecretagent007 · Updated Dec 8, 2025

Solana X402 payment protocol that enables fast, secure, and low-cost on-chain payments.

1
Stars
2
Forks
Rust
Language
Oct 30, 2025
Created

In the AI payments ecosystem

Solana-X402-Payment-Protocol is an early-stage Rust project in the AI payments / x402 ecosystem, focused on payment, x402. It currently has 1 GitHub stars and 2 forks, and sits alongside related tools like internet-court-skill, ProwlFi, aixyz.

README.md View on GitHub →

Solana X402 Payment Protocol

A simple, secure payment protocol smart contract on Solana blockchain for handling escrow payments and transfers.

GitHub License Telegram

✨ Features

  • 💰 Initialize Payment - Create payment with unique ID
  • Complete Payment - Transfer SOL from payer to recipient
  • Cancel Payment - Cancel pending payment
  • 📊 Payment Tracking - Track status (Pending, Completed, Cancelled)
  • 🔒 Secure - PDA-based with proper validation
  • Timestamped - Automatic timestamp tracking

🚀 Quick Start

1️⃣ Install Dependencies

npm install

2️⃣ Build the Program

cargo build-bpf

3️⃣ Deploy to Devnet

# Configure Solana CLI
solana config set --url https://api.devnet.solana.com

# Airdrop SOL
solana airdrop 2

# Deploy
solana program deploy target/deploy/solana_x402_payment_protocol.so

4️⃣ Update Your Program ID

Replace YOUR_PROGRAM_ID_HERE in client/example.ts with your deployed program ID.

5️⃣ Run Example

npm run example

📦 Installation

Requirements:

# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

# Clone repository
git clone https://github.com/topsecretagent007/Solana-X402-Payment-Protocol.git
cd Solana-X402-Payment-Protocol

# Install dependencies
npm install

💻 Usage

import { PaymentProtocolClient } from './client/payment-client';
import { Connection, Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';

const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
const programId = new PublicKey('YOUR_PROGRAM_ID');
const client = new PaymentProtocolClient(connection, programId);

// Initialize payment
await client.initializePayment(payer, recipient, 0.5 * LAMPORTS_PER_SOL, 'PAYMENT-001');

// Complete payment
await client.completePayment(payer, recipient, 'PAYMENT-001');

// Cancel payment
await client.cancelPayment(payer, 'PAYMENT-001');

// Get payment info
const payment = await client.getPayment(payer.publicKey, 'PAYMENT-001');

🔧 API Reference

Method Description
initializePayment(payer, recipient, amount, paymentId) Create a new payment
completePayment(payer, recipient, paymentId) Complete and transfer funds
cancelPayment(payer, paymentId) Cancel a pending payment
getPayment(payer, paymentId) Get payment details
paymentExists(payer, paymentId) Check if payment exists
getPaymentStatus(payer, paymentId) Get payment status

📊 Payment Status

Status Value Description
Pending 0 Payment created, waiting for action
Completed 1 Funds transferred to recipient
Cancelled 2 Payment cancelled, no transfer

🛠️ Development

# Run tests
cargo test-bpf

# Build for production
cargo build-bpf --release

# Run example
npm run example

# Compile TypeScript
npm run compile

📚 Documentation

🔒 Security

⚠️ Important: This is for educational purposes. Before production:

  • Conduct a professional security audit
  • Test thoroughly on devnet
  • Implement additional validation as needed
  • Consider timeout mechanisms

📞 Contact & Support

All Rust crates →