Pay-as-you-Go subscription protocol for Web3 using PYUSD. Transparent & flexible payment experience
The PYUSD "Pay-as-you-Go" Subscription Protocol is a decentralized solution developed to solve the problems of traditional fixed-fee subscriptions (fatigue, paying for unused time, cancellation difficulties). It utilizes the PayPal USD (PYUSD) stablecoin on the Ethereum Sepolia testnet. Users maintain control over their funds, allowing the contract to pull PYUSD from their wallet using the ERC20 transferFrom mechanism only after an explicit approve transaction and only for the period they subscribe to. Access control is managed by a gas-less, on-chain check (isSubscriberActive) based on the subscription's expiresAt timestamp. This model offers Web3 applications (DeFi, GameFi, content platforms) a fair, transparent, and completely user-controlled revenue stream.
The core PYUSDSubscription smart contract was developed with Solidity 0.8.28. The backend was built using Hardhat 3, including comprehensive Solidity tests (.t.sol) that leveraged Foundry's cheatcodes (via Hardhat) for features like time manipulation (vm.warp). Contract deployment was managed via Hardhat Ignition. The protocol uses the standard ERC20 approve and transferFrom for a "pull payment" system. The Frontend was built with React 18.x, TypeScript, and Vite. Wagmi 2.x (built on Viem) was used for seamless interaction with the smart contract, and ConnectKit provided the wallet connection UI. Viem was a key technology used across both the backend and frontend as a modern, lightweight Ethereum library to facilitate a user-friendly interface where users can easily check their Sepolia PYUSD balance and execute the approve and subscribe transactions.

