Back to Home
TypeScript Clientv0.1.0 · Anchor 0.30+

@tidepay/sdk

Lightweight, wallet-agnostic client for creating merchant plans, subscribing to delegated recurring payments, and triggering autonomous billing epochs.

Installation

pnpm add @tidepay/sdk @tidepay/types @solana/web3.js

1. Initializing TidePayClient

The client works with any standard Solana Connection and optionally accepts a wallet adapter:

import { Connection } from "@solana/web3.js";
import { TidePayClient } from "@tidepay/sdk";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const client = new TidePayClient(connection);

2. Core Method Primitives

PDA Derivation Helpers
  • • client.findMerchantPlanPda(merchant, planId)
  • • client.findSubscriptionPda(plan, subscriber)
  • • client.findProgramAuthorityPda()
Instruction Builders
  • • buildInitializePlanInstruction(params)
  • • buildSubscribeInstruction(params)
  • • buildProcessEpochInstruction(params)
  • • buildCancelSubscriptionInstruction(params)

3. Building a Subscribe Instruction

Return raw TransactionInstruction objects for seamless transaction composability:

const { instruction, subscriptionPda } = await client.buildSubscribeInstruction({
  subscriber: wallet.publicKey,
  plan: planPubkey,
  tokenMint: usdcMintPubkey,
  subscriberTokenAccount: subscriberAta,
  merchantTokenAccount: merchantAta,
});

// Bundle into v0 VersionedTransaction or legacy Transaction
tx.add(instruction);
Open Source Package

Explore full TypeScript implementation and test suites.

SDK on GitHub