Navigation
Quickstart
The Paygo TypeScript client makes it easy to interact with the Paygo protocol. It handles transaction creation, signing, and submission, supporting both local private key signing and viem wallet integration.
Installation
Install the Paygo TypeScript client using bun:
Basic Usage
Here's a simple example showing how to set up the client, get test tokens, and make a transfer:
Features
Accounts
Accounts in Paygo are similar to EVM-style addresses but with a simpler structure. Each account has an address, a nonce for transaction ordering, and a balance in cents. These accounts form the foundation of the Paygo system, allowing users to interact with it.
Delegations
Delegations provide a powerful way to manage shared funds and create payment authorization systems. They allow one account (the delegator) to grant spending authority to another account (the delegate), with controls for maximum spending amounts and expiration dates. This enables use cases like managing shared funds, creating payment authorization systems, and implementing multi-signature-like functionality.
Escrows
Escrows in Paygo provide a flexible way to handle conditional payments and time-locked funds. They allow you to lock funds with specific conditions that can be satisfied with an SP1 zk proof, making them ideal for multi-party agreements and conditional payments. Each escrow has a unique ID, locked amount, expiration date, and optional fulfiller address and proof requirements. Funds can be released when conditions are met or when the escrow expires.
Transaction History
Paygo maintains a complete and verifiable history of all transactions. You can query transactions by their hash, the signer's address, or the block number they were included in. This comprehensive history allows for easy tracking and verification of all operations on the network, ensuring transparency and auditability.
Viem Integration
The Paygo client supports integration with viem, a TypeScript interface for Ethereum that provides a consistent API for interacting with Ethereum nodes. This allows you to use Paygo with any viem-compatible wallet or provider.
Switching Between Signing Methods
The client allows you to switch between different signing methods (local private key and viem wallet) based on your needs.