Skip to content

spec for API monetisation using payment channels + stablecoins instead of API keys

Notifications You must be signed in to change notification settings

Dhruv-2003/pipegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PipeGate

The Web3 Stripe for APIs. Create payment channels, make API calls, payments happen automatically. No API keys, no gas fees per request, just use your wallet and start building.

Screenshot 2024-11-17 at 12 32 48 AM

Description

PipeGate is a decentralized API monetization protocol that changes how APIs handle payments and access control. By replacing traditional API keys with payment channels and one time payments, it enables true pay-per-call pricing without gas fees for each request.

The protocol consists of three main components:

  • A client-side middleware that automatically handles payment channel creation, request signing, and payment management
  • A server-side middleware that verifies signatures and manages payment channel states
  • A smart contract for a new payment channel creation

Key Features:

  • Gasless microtransactions using payment channels
  • Automatic request signing and payment handling
  • No API keys needed - just your wallet
  • Real-time balance updates
  • Self-served onboarding

This solves three critical problems:

  • Too many API keys for each product
  • Complex API & Auth management for providers
  • High payment gateway fees

Demo

How it's made

PipeGate is built using a stack of modern Web3 technologies and standard web protocols:

Core Components:

  1. Smart Contracts (Solidity):

    • Payment Channel Factory for channel creation
    • Channel contracts for handling payments
    • Beacon Proxy pattern for low deployment fees
  2. Client SDK (TypeScript):

    • Built with viem for blockchain interactions
    • Axios interceptors for seamless request modification
    • State management for channel tracking
  3. Server Middleware (Rust):

    • Signature verification
    • Payment channel state management
    • One time payment verification for API calls

Architecture & Flow

Screenshot 2024-12-12 at 12 09 55 PM

Publish SDKs & Libraries

How to use

For API Providers

  1. Register your API:

    • Add your pricing info to ChannelFactory by registering yourselves.
    • Can directly interact with contract using cast here
    • Or using a scripts here
  2. Add the server-side middleware:

    • Add the PipeGate server middleware to your API server
    • Supported with axum in rust lib
  3. Close the channel & withdraw

    • Directly interact with contract using cast with the command
    • Using the rust library as well example

For API Consumers

  1. Create a payment channel:

    • Use the client-side SDK to create a payment channel with this script
    • Supported with sdk in typescript lib
    • Or directly interact with contract using cast here
  2. Make API calls:

    • Use the client-side SDK to add interceptor to your axios instance with this sdk

With this project, we've tried to make the complex payment channel system completely invisible to both API providers and consumers, while maintaining security and efficiency.

Team

About

spec for API monetisation using payment channels + stablecoins instead of API keys

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published