Overview

The Azoth SDK provides a simple and efficient way to integrate crypto subscriptions, one-time payments, and revenue splits into your platform.

It abstracts away the complexity of direct blockchain interactions, giving merchants in high-risk industries (adult, betting, VPN, forex, etc.) a straightforward toolkit to start accepting stablecoin payments.

Features

  • Easy Integration – Simple interface for adding AzothPay payments to your platform.

  • Multi-Chain Support – Works across major EVM networks (Ethereum, Polygon, BNB Chain, Avalanche, Base, Arbitrum, etc.).

  • Stablecoin Ready – Native support for ERC-20 stablecoins (USDT, USDC, PYUSD).

  • Developer-Friendly – Typed definitions and utility functions for rate conversions and data formatting.

  • Flexible Contracts – Supports multiple contract versions for backward compatibility.

  • Gasless Options – Includes BySig methods to enable gasless user transactions.

  • Robust Transaction Handling – Comprehensive tools for monitoring and managing payment flows.

Quick Start

import { ethers } from 'ethers';
import { AzothSDK, formatOutput, convertRateToPeriod, RatePeriod } from '@azothpay/sdk';

// Create an Ethereum provider
const provider = new ethers.JsonRpcProvider('YOUR_RPC_URL');

// Create a signer if you need to send transactions
const privateKey = 'YOUR_PRIVATE_KEY';
const signer = new ethers.Wallet(privateKey, provider);

// Create a Azoth SDK instance
const azoth = AzothSDK.create(
  signer,      // Or provider if you only need read-only operations
  'polygon',   // Network name (default is 'polygon')
  'USDT'       // Token symbol (default is 'USDT')
);

async function getBalance() {
  const rawBalance = await azoth.balanceOf();
  // Convert raw balance to readable format
  const readableBalance = formatOutput(BigInt(rawBalance), 18);
  console.log(`Your balance: ${readableBalance} USDT`);
}

// Example subscription
async function subscribeToAuthor() {
  const authorAddress = '0x...';  // The address to subscribe to
  const amountPerMonth = 10;      // Amount in tokens per month
  
  const tx = await azoth.subscribe(authorAddress, amountPerMonth);
  await tx.wait();
  console.log('Successfully subscribed!');
}

// Example getting user info with rate conversion
async function getUserInfo() {
  const userInfo = await papaya.getUserInfo();
  
  // Convert raw blockchain data to human-readable format
  const formattedInfo = {
    balance: formatOutput(BigInt(userInfo.balance), 18),
    // Convert per-second rates to monthly rates
    incomeRate: convertRateToPeriod(Number(formatOutput(userInfo.incomeRate, 18)), RatePeriod.MONTH),
    outgoingRate: convertRateToPeriod(Number(formatOutput(userInfo.outgoingRate, 18)), RatePeriod.MONTH),
    updated: new Date(Number(userInfo.updated) * 1000).toISOString()
  };
  
  console.log(`Balance: ${formattedInfo.balance} USDT`);
  console.log(`Monthly income: ${formattedInfo.incomeRate} USDT`);
  console.log(`Monthly outgoing: ${formattedInfo.outgoingRate} USDT`);
}

Last updated