Meta API

Browser-compatible meta-transaction client for AzothPay Gasless UX for subscriptions, payments, deposits & withdrawals – powered by EIP-712 and a relayer network.

βœ… No axios – uses native fetch()

βœ… Full EIP-712 signing (ethers-compatible)

βœ… Non-custodial: user signs off-chain, relayer broadcasts on-chain

βœ… Works in modern browsers and bundlers (Webpack, Vite, etc.)


πŸ“¦ Installation & Initialization

npm install @azothpay/api ethers
import { AzothPayMetaApiClient } from '@azothpay/api/browser';

const metaClient = new AzothPayMetaApiClient(
  'https://azothpay.com',     // production endpoint
  'bsc-usdt',                 // 'bsc-usdc' | 'bsc-usdt' | 'pol-usdc'| 'pol-usdt'
  'your-api-key'              // issued after KYB and onboarding
);

Constructor Parameters

Param
Required
Description

baseUrl

βœ…

API base URL, e.g. 'https://azothpay.com'

contract

❌

Contract identifier: 'bsc-usdc' | 'bsc-usdt' | 'pol-usdc'| 'pol-usdt'

apiKey

βœ…

API key (issued by AzothPay during onboarding)

provider

❌

Optional ethers.Provider, can be set later via .setProvider()

πŸ” All requests automatically include the header: x-api-key: <your-api-key>


πŸ”‘ Meta-Transaction Concept in AzothPay

Meta-transactions allow users to perform operations without paying gas themselves:

  1. Client β†’ API: call prepare*MetaTransaction(...) β†’ get structured transactionData

  2. Client β†’ Wallet: call signMetaTransaction(...) β†’ sign EIP-712 message with traits

  3. Client β†’ API: call executeMetaTransaction(...) β†’ relayer submits the tx on-chain

Result: the user does not pay gas; they only pay according to your business logic (subscriptions, payments, etc.). Gas is paid by the relayer, which you or AzothPay control.


πŸ“š Method Overview

1. Prepare Meta-Transactions (off-chain)

These methods prepare data for EIP-712 signing and later execution.

Method
Params
Returns

prepareSubscriptionMetaTransaction(params)

{ from, author, subscriptionRate, projectId }

{ from, method, data }

Prepares subscribe(...) call

prepareCancelSubscriptionMetaTransaction(author, params)

author, { from }

{ from, method, data }

Prepares unsubscribe(author) call

preparePaymentMetaTransaction(params)

{ from, to, amount }

from, method, data }

Prepares pay(to, amount) call

prepareDepositMetaTransaction(params)

{ from, amount, isPermit2? }

{ from, method, data }

Prepares deposit(amount, isPermit2) call

prepareWithdrawMetaTransaction(params)

{ from, amount, to? }

{ from, method, data }

Prepares withdraw(amount) or withdrawTo(to, amount) call

πŸ“Œ amount and subscriptionRate in token smallest units (wei-like). For USDT/USDC (18 decimals), multiply USD amount by 1e18: 50 USDT β†’ '50000000000000000000'. πŸ“Œ amount in prepareDepositMetaTransaction() in token should be same as for native token. example: USDT on Polygon (6 decimals), multiply USD amount by 1e6: 50 USDT β†’ '50000000'.


2. Signing (client-side, EIP-712)

signMetaTransaction(transactionData, signer, contractAddress, chainId, relayerAddress)

Signs prepared meta-transaction using EIP-712.

Param
Type
Description

transactionData

object

Result of any prepare*MetaTransaction() call

signer

ethers.Signer

Ethers signer, e.g. provider.getSigner() from MetaMask

contractAddress

string

AzothPay contract address (0x...)

chainId

number

Chain ID (e.g. 137 for Polygon)

relayerAddress

string

Address of the relayer (operated by you or AzothPay)

Returns:


3. Execute Meta-Transaction (via relayer)

executeMetaTransaction(signedTransaction)

Sends signed meta-transaction payload to the relayer API. The relayer then broadcasts the corresponding on-chain transaction.

Returns (typical):

  • txHash: transaction hash after broadcast

  • status: 'pending' | 'confirmed' | 'failed'

  • On error – HTTP 4xx/5xx with error description

⚠️ The relayer must be authorized in the AzothPay contract.

Contact AzothPay if you want to use the shared relayer or run your own.


πŸš€ Convenience β€œAll-in-One” Methods

These helpers encapsulate: prepare β†’ sign β†’ execute.

Method

createSubscriptionViaMetaTransaction(params, signer, contractAddress, chainId, relayerAddress)

Gasless subscription creation

cancelSubscriptionViaMetaTransaction(author, params, signer, contractAddress, chainId, relayerAddress)

Gasless subscription cancellation

makePaymentViaMetaTransaction(...)

Gasless one-off payment

depositFundsViaMetaTransaction(...)

Gasless deposit

withdrawFundsViaMetaTransaction(...)

Gasless withdraw

Example: Gasless Subscription


πŸ” Additional Methods

Method
Description

getNonce(address)

Returns the current nonce for given address (for replay protection)

setProvider(provider)

Sets/updates ethers.Provider (useful to fetch chainId etc.)


⚠️ Important Notes

  1. Relayer security

    Only trusted relayers should be allowed to execute meta-transactions.

    AzothPay can provide a shared relayer or help you deploy your own.

  2. Signature deadline

    Each meta-transaction has a deadline (unix timestamp). After that time, the contract rejects the signature.

  3. Replay protection

    Contracts validate (nonceType, nonce) pairs – each combination is unique and can be used only once.

  4. EIP-712 support

    Wallet must support eth_signTypedData_v4 (MetaMask, WalletConnect, Coinbase Wallet, etc.).


πŸ›‘οΈ Security & Compatibility

  • βœ… Supports ethers.js v5 and v6

  • βœ… Uses native fetch() only (no axios)

  • βœ… Compatible with modern bundlers (Webpack, Vite, etc.)

  • βœ… Relies on BigInt – runtime will check for availability

  • βœ… Default HTTP timeout: 10 seconds for API calls


πŸ’‘ AzothPay is non-custodial, audited, and stablecoin-native infrastructure for: adult, iGaming, VPN, donations.

Last updated