Main API
Browser-compatible JavaScript API client for AzothPay Streaming payments, subscriptions, and revenue splits with no axios dependency.
✅ Works in modern browsers
✅ Uses native fetch()
✅ Non-custodial, signer-based transaction execution
✅ Supports USDT/USDC on Polygon and L2s (Arbitrum, Base, etc.)
📦 Installation
npm install @azothpay/api ethersℹ️ Requires ethers.js (v5 or v6). For browser bundles, use [email protected] or the ESM build of ethers@6.
🚀 Quick Start
import { AzothPayApiClient } from '@azothpay/api/browser';
import { ethers } from 'ethers';
// 1. Connect user wallet (MetaMask / WalletConnect)
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
// 2. Create AzothPay client
const client = new AzothPayApiClient(
'https://azothpay.com', // production endpoint
'bsc-usdc', // 'bsc-usdc' | 'bsc-usdt' | 'pol-usdc'| 'pol-usdt'
'your-api-key' // issued after KYB and onboarding
);
// 3. Create and send a subscription in one call
const receipt = await client.createSubscriptionAndSend(
{
author: '0x742d35Cc6634C0532925a3b8D4C9f2a93A9E3F1A', // creator or merchant address
subscriptionRate: '50000000000000000000', // 50 USDT (18 decimals)
projectId: 0
},
signer,
1 // number of confirmations
);⚙️ Client Initialization
Constructor Parameters
baseUrl
string
✅
API base URL, e.g. 'https://azothpay.com'
contract
string
❌
Contract identifier: 'bsc-usdc', 'bsc-usdt', 'pol-usdc', 'pol-usdt'
apiKey
string
✅
API key (issued by AzothPay during onboarding)
provider
ethers.providers.Provider
❌
Web3 provider, can be set later via .setProvider()
🔎 API Introspection
getAvailableContracts()
Returns list of supported contracts:
getAvailableContracts()
Promise<{ name: string, address: string }[]>
Available AzothPay contracts
📰 Subscriptions
Core methods to work with subscriptions.
createSubscription(params)
{ author, subscriptionRate, projectId }
Promise<TransactionResponse>
Builds a subscription tx (not sent)
createSubscriptionAndSend(params, signer, confirmations?)
—
Promise<TransactionReceipt>
Creates, signs and sends a subscription
cancelSubscription(author, params)
author, { from }
Promise<TransactionResponse>
Builds a cancel-subscription tx
cancelSubscriptionAndSend(...)
author, params, signer, confirmations?
Promise<TransactionReceipt>
Cancels subscription and sends tx
listSubscriptions(address)
string
Promise<{ subscriptions: Subscription[] }>
Lists active subscriptions for an address
💸 Payments & Funds
One-off payments
makePayment(params)
{ from, to, amount, projectId? }
Promise<TransactionResponse>
Builds a one-off payment transaction
makePaymentAndSend(...)
params, signer, confirmations?
Promise<TransactionReceipt>
Signs and sends a payment
Deposits & withdrawals
depositFunds(params)
{ from, amount }
Promise<TransactionResponse>
Builds a deposit transaction
depositFundsAndSend(...)
params, signer, confirmations?
Promise<TransactionReceipt>
Deposits and sends tx
withdrawFunds(params)
{ from, amount, to? }
Promise<TransactionResponse>
Builds a withdraw transaction
withdrawFundsAndSend(...)
params, signer, confirmations?
Promise<TransactionReceipt>
Withdraws and sends tx
Balance & active streams
getBalance(...)
address
Promise<{ balance: string, streamingOut: string, streamingIn: string[] }>
Balance and active streams for address
⚡ Advanced Operations
Some clients use additional methods for gas optimization and bulk operations.
createBatchSubscriptions(...)
{ items: { author, rate, projectId }[] }
Creates multiple subscriptions in a single call
processBatchPayments(...)
{ items: { to, amount }[] }
Bulk payouts (affiliates, models, partners)
liquidateAccount(params)
{ from, target }
Forced liquidation when funds are insufficient
getAnalytics(params?)
{ projectId?, startDate?, endDate? }
Basic analytics for flows and revenue
✍️ Manual Signing & Sending
If you want to separate tx preparation from signing/sending, use low-level helpers:
Signing helpers
signAndSendTransaction(tx, signer)
Signs and sends a transaction. Returns TransactionResponse.
signAndSendTransactionAndWait(tx, signer, confirmations = 1)
Signs, sends and waits for N confirmations. Returns TransactionReceipt.
🔧 Provider & HTTP Configuration
Changing provider after initialization
HTTP settings
All calls use fetch() with:
default timeout: 10 seconds;
default headers:
There is a low-level _makeRequest() method that allows overriding headers/timeouts, but it is not recommended to use it directly in production.
🚨 Error Handling
All methods throw exceptions with readable messages:
Typical error categories:
validation errors (400 Bad Request);
missing permissions / invalid apiKey (401/403);
network errors (Request timeout, Failed to fetch, etc.);
on-chain errors (contract revert) depending on business logic.
ℹ️ Meta-transactions
This package implements direct signer-based on-chain transactions.
Gasless / meta-transaction support is provided by a separate client AzothPayMetaApiClient and requires a relayer service.
⚠️ To enable meta-transactions (EIP-712, gasless UX), please contact the AzothPay team.
Meta API📬 Support & Contacts
Tech support: [email protected]
Telegram: https://t.me/azothpay
Last updated