@tributary-so/sdk
    Preparing search index...

    Class Tributary

    Main SDK class for interacting with the Tributary recurring payments protocol on Solana. Provides methods to create payment gateways, user accounts, payment policies, and execute payments.

    const connection = new Connection("https://api.mainnet-beta.solana.com");
    const wallet = new Wallet(Keypair.generate());
    const sdk = new Tributary(connection, wallet);

    // Initialize the protocol (admin only)
    const initIx = await sdk.initialize(adminPublicKey);
    Index

    Constructors

    • Creates a new Tributary SDK instance.

      Parameters

      • connection: Connection

        Solana RPC connection to use for all operations

      • wallet: Wallet

        Wallet containing the keypair for signing transactions

      Returns Tributary

    Properties

    connection: Connection

    Solana RPC connection

    program: Program<Tributary>

    Anchor program instance for the Recurring Payments contract

    programId: PublicKey

    Public key of the deployed program

    provider: AnchorProvider

    Anchor provider with wallet and connection

    Methods

    • Changes the gateway fee in basis points for a payment gateway. Only the gateway authority can change the fee.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      • newFeeBps: number

        New gateway fee in basis points (0-10000)

      Returns Promise<TransactionInstruction>

      Transaction instruction to change the gateway fee bps

    • Changes the fee recipient for a payment gateway. Only the gateway authority can change the fee recipient.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      • newFeeRecipient: PublicKey

        Public key of the new fee recipient

      Returns Promise<TransactionInstruction>

      Transaction instruction to change the gateway fee recipient

    • Changes the signer authorized to execute payments for a gateway. Only the gateway authority can change the signer.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the current gateway authority

      • newSigner: PublicKey

        Public key of the new signer

      Returns Promise<TransactionInstruction>

      Transaction instruction to change the gateway signer

    • Changes the status of a payment policy (active or paused). Only the policy owner can change the status.

      Parameters

      • tokenMint: PublicKey

        Public key of the token mint

      • policyId: number

        ID of the policy to modify

      • newStatus: { active: {} } | { paused: {} }

        New status for the policy

      Returns Promise<TransactionInstruction>

      Transaction instruction to change the policy status

    • Parameters

      • signature: string
      • commitment: "processed" | "confirmed" | "finalized" = "confirmed"
      • interval: number = 150
      • timeout: number = 60000

      Returns Promise<SignatureStatus>

    • Creates a milestone payment policy with full setup including ATAs, user payment account, and token approvals. Use getCreateMilestonePolicyInstruction() for just the instruction without setup.

      Parameters

      • tokenMint: PublicKey

        Public key of the token mint

      • recipient: PublicKey

        Public key of the payment recipient

      • gateway: PublicKey

        Public key of the payment gateway

      • milestoneAmounts: BN[]

        Array of amounts for each milestone (up to 4)

      • milestoneTimestamps: BN[]

        Array of timestamps when each milestone is due

      • releaseCondition: number

        Bitmap: bit0=check due date, bit1=gateway signer, bit2=owner signer, bit3=recipient signer. Bits 1-3 mutually exclusive.

      • memo: number[]

        Memo bytes for the payment policy

      • OptionalapprovalAmount: BN

        Optional specific approval amount (calculated automatically if not provided)

      • OptionalexecuteImmediately: boolean

        Whether to execute the first milestone immediately if due

      • OptionalreferralCode: string

      Returns Promise<TransactionInstruction[]>

      Array of transaction instructions for complete setup

    • Creates a pay-as-you-go payment policy with full setup including ATAs, user payment account, and token approvals. Use getCreatePayAsYouGoPolicyInstruction() for just the instruction without setup.

      Parameters

      • tokenMint: PublicKey

        Public key of the token mint

      • recipient: PublicKey

        Public key of the payment recipient

      • gateway: PublicKey

        Public key of the payment gateway

      • maxAmountPerPeriod: BN

        Maximum amount allowed per period

      • maxChunkAmount: BN

        Maximum amount that can be claimed in one go

      • periodLengthSeconds: BN

        Length of each period in seconds

      • memo: number[]

        Memo bytes for the payment policy

      • OptionalapprovalAmount: BN

        Optional specific approval amount (calculated automatically if not provided)

      • OptionalreferralCode: string

      Returns Promise<TransactionInstruction[]>

      Array of transaction instructions for complete setup

    • Creates a new payment gateway for processing recurring payments. Gateways can charge fees and execute payments on behalf of users.

      Parameters

      • authority: PublicKey

        Public key that controls the gateway

      • gatewayFeeBps: number

        Fee in basis points (100 bps = 1%) charged by the gateway

      • gatewayFeeRecipient: PublicKey

        Public key that receives gateway fees

      • name: string

        Display name for the gateway (max 32 characters)

      • url: string

        Website URL for the gateway (max 64 characters)

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the payment gateway

    • Creates a referral account for the current user within a specific gateway. The referral account stores the user's referral code and tracks their referrer (who referred them).

      Parameters

      • gateway: PublicKey

        Public key of the gateway this referral account belongs to

      • referralCode: string

        6-character alphanumeric referral code for this user

      • Optionalreferrer: PublicKey

        Optional public key of the user who referred this user (L1 referrer)

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the referral account

    • Creates a complete subscription setup including ATAs, user payment account, policy, and token approvals. This is the high-level method for creating subscriptions that handles all the setup automatically.

      Parameters

      • tokenMint: PublicKey

        Public key of the token to be paid

      • recipient: PublicKey

        Public key that receives the payments

      • gateway: PublicKey

        Public key of the gateway that will execute payments

      • amount: BN

        Amount to pay per interval (in smallest token units)

      • autoRenew: boolean

        Whether the subscription should auto-renew

      • maxRenewals: number | null

        Maximum number of renewals allowed (null for unlimited)

      • paymentFrequency: DecodeEnum

        How often payments should occur

      • memo: number[]

        Memo bytes to include with payments (max 64 bytes)

      • OptionalstartTime: BN | null

        When the first payment should occur (defaults to now)

      • OptionalapprovalAmount: BN

        Amount to approve for token delegation (calculated automatically if not provided)

      • OptionalexecuteImmediately: boolean

        Whether to execute the first payment immediately

      • OptionalreferralCode: string

        Optional 6-character referral code to associate with this subscription

      Returns Promise<TransactionInstruction[]>

      Array of transaction instructions for the complete subscription setup

    • Creates a user payment account for tracking payments in a specific token. Each user needs one account per token mint they want to use for payments.

      Parameters

      • tokenMint: PublicKey

        Public key of the token mint for payments

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the user payment account

    • Deletes a payment gateway. Only the protocol admin can delete gateways.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      Returns Promise<TransactionInstruction>

      Transaction instruction to delete the payment gateway

    • Deletes a payment policy permanently. Only the policy owner can delete their policies.

      Parameters

      • tokenMint: PublicKey

        Public key of the token mint

      • policyId: number

        ID of the policy to delete

      Returns Promise<TransactionInstruction>

      Transaction instruction to delete the payment policy

    • Executes a payment for a given payment policy. This method handles the complete payment execution flow including fee calculations and token transfers.

      Parameters

      • paymentPolicyPda: PublicKey

        Public key of the payment policy account

      • OptionalpaymentAmount: BN

        Amount to pay (optional for subscription/milestone, required for pay-as-you-go)

      • Optionalrecipient: PublicKey

        Public key of the payment recipient (optional if in policy)

      • OptionaltokenMint: PublicKey

        Public key of the token mint (optional if in policy)

      • Optionalgateway: PublicKey

        Public key of the payment gateway (optional if in policy)

      • Optionaluser: PublicKey

        Public key of the payment user (optional if in policy)

      Returns Promise<TransactionInstruction[]>

      Array of transaction instructions including ATA creation and payment execution

    • Retrieves all payment gateways in the protocol.

      Returns Promise<
          {
              account: {
                  authority: PublicKey;
                  bump: number;
                  createdAt: BN;
                  customProtocolFeeBps: number;
                  featureFlags: number;
                  feeRecipient: PublicKey;
                  gatewayFeeBps: number;
                  isActive: boolean;
                  name: number[];
                  padding: number[];
                  padding1: BN;
                  referralAllocationBps: number;
                  referralTiersBps: number[];
                  signer: PublicKey;
                  url: number[];
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment gateway accounts with their public keys

    • Retrieves all payment policies in the protocol.

      Returns Promise<
          {
              account: {
                  bump: number;
                  createdAt: BN;
                  gateway: PublicKey;
                  memo: number[];
                  padding: number[];
                  paymentCount: number;
                  policyId: number;
                  policyType: DecodeEnum<
                      {
                          kind: "enum";
                          variants: [
                              {
                                  fields: [
                                      { name: "amount"; type: "u64" },
                                      { name: "autoRenew"; type: "bool" },
                                      { name: "maxRenewals"; type: { option: ... } },
                                      { name: "paymentFrequency"; type: { defined: ... } },
                                      { name: "nextPaymentDue"; type: "i64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "subscription";
                              },
                              {
                                  fields: [
                                      { name: "milestoneAmounts"; type: { array: ... } },
                                      { name: "milestoneTimestamps"; type: { array: ... } },
                                      { name: "currentMilestone"; type: "u8" },
                                      { name: "releaseCondition"; type: "u8" },
                                      { name: "totalMilestones"; type: "u8" },
                                      { name: "escrowAmount"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "milestone";
                              },
                              {
                                  fields: [
                                      { name: "maxAmountPerPeriod"; type: "u64" },
                                      { name: "maxChunkAmount"; type: "u64" },
                                      { name: "periodLengthSeconds"; type: "u64" },
                                      { name: "currentPeriodStart"; type: "i64" },
                                      { name: "currentPeriodTotal"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "payAsYouGo";
                              },
                          ];
                      },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  recipient: PublicKey;
                  status: DecodeEnum<
                      { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  totalPaid: BN;
                  updatedAt: BN;
                  userPayment: PublicKey;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment policy accounts with their public keys

    • Retrieves all user payment accounts in the protocol.

      Returns Promise<
          {
              account: {
                  activePoliciesCount: number;
                  bump: number;
                  createdAt: BN;
                  createdPoliciesCount: number;
                  isActive: boolean;
                  owner: PublicKey;
                  padding: number[];
                  tokenAccount: PublicKey;
                  tokenMint: PublicKey;
                  updatedAt: BN;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of user payment accounts with their public keys

    • Retrieves all user payment accounts owned by a specific user.

      Parameters

      • owner: PublicKey

        Public key of the user

      Returns Promise<
          {
              account: {
                  activePoliciesCount: number;
                  bump: number;
                  createdAt: BN;
                  createdPoliciesCount: number;
                  isActive: boolean;
                  owner: PublicKey;
                  padding: number[];
                  tokenAccount: PublicKey;
                  tokenMint: PublicKey;
                  updatedAt: BN;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of user payment accounts owned by the specified user

    • Gets a transaction instruction to create a milestone payment policy. This is a low-level method that returns only the instruction. Use createMilestonePayment() for the full setup including ATAs and approvals.

      Parameters

      • tokenMint: PublicKey

        Public key of the token to be paid

      • recipient: PublicKey

        Public key that receives the payments

      • gateway: PublicKey

        Public key of the gateway that will execute payments

      • milestoneAmounts: BN[]

        Array of amounts for each milestone (up to 4)

      • milestoneTimestamps: BN[]

        Array of timestamps when each milestone is due

      • releaseCondition: number

        Bitmap: bit0=check due date, bit1=gateway signer, bit2=owner signer, bit3=recipient signer. Bits 1-3 mutually exclusive.

      • memo: number[]

        Memo bytes to include with payments (max 64 bytes)

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the milestone payment policy

    • Gets a transaction instruction to create a pay-as-you-go payment policy. This is a low-level method that returns only the instruction. Use createPayAsYouGoPayment() for the full setup including ATAs and approvals.

      Parameters

      • tokenMint: PublicKey

        Public key of the token to be paid

      • recipient: PublicKey

        Public key that receives the payments

      • gateway: PublicKey

        Public key of the gateway that will execute payments

      • maxAmountPerPeriod: BN

        Maximum amount allowed per period

      • maxChunkAmount: BN

        Maximum amount that can be claimed in a single payment

      • periodLengthSeconds: BN

        Length of each period in seconds

      • memo: number[]

        Memo bytes to include with payments (max 64 bytes)

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the pay-as-you-go payment policy

    • Gets a transaction instruction to create a subscription payment policy. This is a low-level method that returns only the instruction. Use createSubscription() for the full setup including ATAs and approvals.

      Parameters

      • tokenMint: PublicKey

        Public key of the token to be paid

      • recipient: PublicKey

        Public key that receives the payments

      • gateway: PublicKey

        Public key of the gateway that will execute payments

      • amount: BN

        Amount to pay per interval (in smallest token units)

      • autoRenew: boolean

        Whether the subscription should auto-renew

      • maxRenewals: number | null

        Maximum number of renewals allowed (null for unlimited)

      • paymentFrequency: DecodeEnum

        How often payments should occur

      • memo: number[]

        Memo bytes to include with payments (max 64 bytes)

      • OptionalstartTime: BN | null

        When the first payment should occur (defaults to now)

      Returns Promise<TransactionInstruction>

      Transaction instruction to create the subscription payment policy

    • Gets a Payment Gateway PDA for the specified authority.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      Returns PdaResult

      PdaResult containing the PDA address and bump

    • Fetches a specific payment gateway account by its address.

      Parameters

      • gatewayAddress: PublicKey

        Public key of the payment gateway account

      Returns Promise<
          | {
              authority: PublicKey;
              bump: number;
              createdAt: BN;
              customProtocolFeeBps: number;
              featureFlags: number;
              feeRecipient: PublicKey;
              gatewayFeeBps: number;
              isActive: boolean;
              name: number[];
              padding: number[];
              padding1: BN;
              referralAllocationBps: number;
              referralTiersBps: number[];
              signer: PublicKey;
              url: number[];
          }
          | null,
      >

      The payment gateway account data or null if not found

    • Retrieves all payment policies executed by the specified gateway.

      Parameters

      • gateway: PublicKey

        Public key of the payment gateway

      Returns Promise<
          {
              account: {
                  bump: number;
                  createdAt: BN;
                  gateway: PublicKey;
                  memo: number[];
                  padding: number[];
                  paymentCount: number;
                  policyId: number;
                  policyType: DecodeEnum<
                      {
                          kind: "enum";
                          variants: [
                              {
                                  fields: [
                                      { name: "amount"; type: "u64" },
                                      { name: "autoRenew"; type: "bool" },
                                      { name: "maxRenewals"; type: { option: ... } },
                                      { name: "paymentFrequency"; type: { defined: ... } },
                                      { name: "nextPaymentDue"; type: "i64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "subscription";
                              },
                              {
                                  fields: [
                                      { name: "milestoneAmounts"; type: { array: ... } },
                                      { name: "milestoneTimestamps"; type: { array: ... } },
                                      { name: "currentMilestone"; type: "u8" },
                                      { name: "releaseCondition"; type: "u8" },
                                      { name: "totalMilestones"; type: "u8" },
                                      { name: "escrowAmount"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "milestone";
                              },
                              {
                                  fields: [
                                      { name: "maxAmountPerPeriod"; type: "u64" },
                                      { name: "maxChunkAmount"; type: "u64" },
                                      { name: "periodLengthSeconds"; type: "u64" },
                                      { name: "currentPeriodStart"; type: "i64" },
                                      { name: "currentPeriodTotal"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "payAsYouGo";
                              },
                          ];
                      },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  recipient: PublicKey;
                  status: DecodeEnum<
                      { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  totalPaid: BN;
                  updatedAt: BN;
                  userPayment: PublicKey;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment policies executed by the gateway

    • Retrieves all payment policies where the specified user is the recipient.

      Parameters

      • user: PublicKey

        Public key of the payment recipient

      Returns Promise<
          {
              account: {
                  bump: number;
                  createdAt: BN;
                  gateway: PublicKey;
                  memo: number[];
                  padding: number[];
                  paymentCount: number;
                  policyId: number;
                  policyType: DecodeEnum<
                      {
                          kind: "enum";
                          variants: [
                              {
                                  fields: [
                                      { name: "amount"; type: "u64" },
                                      { name: "autoRenew"; type: "bool" },
                                      { name: "maxRenewals"; type: { option: ... } },
                                      { name: "paymentFrequency"; type: { defined: ... } },
                                      { name: "nextPaymentDue"; type: "i64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "subscription";
                              },
                              {
                                  fields: [
                                      { name: "milestoneAmounts"; type: { array: ... } },
                                      { name: "milestoneTimestamps"; type: { array: ... } },
                                      { name: "currentMilestone"; type: "u8" },
                                      { name: "releaseCondition"; type: "u8" },
                                      { name: "totalMilestones"; type: "u8" },
                                      { name: "escrowAmount"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "milestone";
                              },
                              {
                                  fields: [
                                      { name: "maxAmountPerPeriod"; type: "u64" },
                                      { name: "maxChunkAmount"; type: "u64" },
                                      { name: "periodLengthSeconds"; type: "u64" },
                                      { name: "currentPeriodStart"; type: "i64" },
                                      { name: "currentPeriodTotal"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "payAsYouGo";
                              },
                          ];
                      },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  recipient: PublicKey;
                  status: DecodeEnum<
                      { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  totalPaid: BN;
                  updatedAt: BN;
                  userPayment: PublicKey;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment policies where the user is the recipient

    • Retrieves all payment policies where the specified user is the payer.

      Parameters

      • user: PublicKey

        Public key of the payment user

      Returns Promise<
          {
              account: {
                  bump: number;
                  createdAt: BN;
                  gateway: PublicKey;
                  memo: number[];
                  padding: number[];
                  paymentCount: number;
                  policyId: number;
                  policyType: DecodeEnum<
                      {
                          kind: "enum";
                          variants: [
                              {
                                  fields: [
                                      { name: "amount"; type: "u64" },
                                      { name: "autoRenew"; type: "bool" },
                                      { name: "maxRenewals"; type: { option: ... } },
                                      { name: "paymentFrequency"; type: { defined: ... } },
                                      { name: "nextPaymentDue"; type: "i64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "subscription";
                              },
                              {
                                  fields: [
                                      { name: "milestoneAmounts"; type: { array: ... } },
                                      { name: "milestoneTimestamps"; type: { array: ... } },
                                      { name: "currentMilestone"; type: "u8" },
                                      { name: "releaseCondition"; type: "u8" },
                                      { name: "totalMilestones"; type: "u8" },
                                      { name: "escrowAmount"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "milestone";
                              },
                              {
                                  fields: [
                                      { name: "maxAmountPerPeriod"; type: "u64" },
                                      { name: "maxChunkAmount"; type: "u64" },
                                      { name: "periodLengthSeconds"; type: "u64" },
                                      { name: "currentPeriodStart"; type: "i64" },
                                      { name: "currentPeriodTotal"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "payAsYouGo";
                              },
                          ];
                      },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  recipient: PublicKey;
                  status: DecodeEnum<
                      { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  totalPaid: BN;
                  updatedAt: BN;
                  userPayment: PublicKey;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment policies where the user is the payer

    • Retrieves all payment policies belonging to the specified user payment account.

      Parameters

      • userPayment: PublicKey

        Public key of the user payment PDA

      Returns Promise<
          {
              account: {
                  bump: number;
                  createdAt: BN;
                  gateway: PublicKey;
                  memo: number[];
                  padding: number[];
                  paymentCount: number;
                  policyId: number;
                  policyType: DecodeEnum<
                      {
                          kind: "enum";
                          variants: [
                              {
                                  fields: [
                                      { name: "amount"; type: "u64" },
                                      { name: "autoRenew"; type: "bool" },
                                      { name: "maxRenewals"; type: { option: ... } },
                                      { name: "paymentFrequency"; type: { defined: ... } },
                                      { name: "nextPaymentDue"; type: "i64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "subscription";
                              },
                              {
                                  fields: [
                                      { name: "milestoneAmounts"; type: { array: ... } },
                                      { name: "milestoneTimestamps"; type: { array: ... } },
                                      { name: "currentMilestone"; type: "u8" },
                                      { name: "releaseCondition"; type: "u8" },
                                      { name: "totalMilestones"; type: "u8" },
                                      { name: "escrowAmount"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "milestone";
                              },
                              {
                                  fields: [
                                      { name: "maxAmountPerPeriod"; type: "u64" },
                                      { name: "maxChunkAmount"; type: "u64" },
                                      { name: "periodLengthSeconds"; type: "u64" },
                                      { name: "currentPeriodStart"; type: "i64" },
                                      { name: "currentPeriodTotal"; type: "u64" },
                                      { name: "padding"; type: { array: ... } },
                                  ];
                                  name: "payAsYouGo";
                              },
                          ];
                      },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  recipient: PublicKey;
                  status: DecodeEnum<
                      { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                      DecodedHelper<
                          [
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee bps is changed",
                                  ];
                                  name: "gatewayFeeBpsChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: [
                                      "An event that is thrown when a gateway fee recipient is changed",
                                  ];
                                  name: "gatewayFeeRecipientChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                              {
                                  docs: ["An event that is thrown when a gateway signer is changed"];
                                  name: "gatewaySignerChanged";
                                  type: {
                                      fields: [
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                          { name: ...; type: ... },
                                      ];
                                      kind: "struct";
                                  };
                              },
                          ],
                          EmptyDefined,
                      >,
                  >;
                  totalPaid: BN;
                  updatedAt: BN;
                  userPayment: PublicKey;
              };
              publicKey: PublicKey;
          }[],
      >

      Array of payment policies for the user payment account

    • Fetches a specific payment policy account by its address.

      Parameters

      • policyAddress: PublicKey

        Public key of the payment policy account

      Returns Promise<
          | {
              bump: number;
              createdAt: BN;
              gateway: PublicKey;
              memo: number[];
              padding: number[];
              paymentCount: number;
              policyId: number;
              policyType: DecodeEnum<
                  {
                      kind: "enum";
                      variants: [
                          {
                              fields: [
                                  { name: "amount"; type: "u64" },
                                  { name: "autoRenew"; type: "bool" },
                                  { name: "maxRenewals"; type: { option: "u32" } },
                                  { name: "paymentFrequency"; type: { defined: { name: ... } } },
                                  { name: "nextPaymentDue"; type: "i64" },
                                  { name: "padding"; type: { array: [(...), (...)] } },
                              ];
                              name: "subscription";
                          },
                          {
                              fields: [
                                  { name: "milestoneAmounts"; type: { array: [(...), (...)] } },
                                  { name: "milestoneTimestamps"; type: { array: [(...), (...)] } },
                                  { name: "currentMilestone"; type: "u8" },
                                  { name: "releaseCondition"; type: "u8" },
                                  { name: "totalMilestones"; type: "u8" },
                                  { name: "escrowAmount"; type: "u64" },
                                  { name: "padding"; type: { array: [(...), (...)] } },
                              ];
                              name: "milestone";
                          },
                          {
                              fields: [
                                  { name: "maxAmountPerPeriod"; type: "u64" },
                                  { name: "maxChunkAmount"; type: "u64" },
                                  { name: "periodLengthSeconds"; type: "u64" },
                                  { name: "currentPeriodStart"; type: "i64" },
                                  { name: "currentPeriodTotal"; type: "u64" },
                                  { name: "padding"; type: { array: [(...), (...)] } },
                              ];
                              name: "payAsYouGo";
                          },
                      ];
                  },
                  DecodedHelper<
                      [
                          {
                              docs: ["An event that is thrown when a gateway fee bps is changed"];
                              name: "gatewayFeeBpsChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldFeeBps"; type: "u16" },
                                      { name: "newFeeBps"; type: "u16" },
                                  ];
                                  kind: "struct";
                              };
                          },
                          {
                              docs: [
                                  "An event that is thrown when a gateway fee recipient is changed",
                              ];
                              name: "gatewayFeeRecipientChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldFeeRecipient"; type: "pubkey" },
                                      { name: "newFeeRecipient"; type: "pubkey" },
                                  ];
                                  kind: "struct";
                              };
                          },
                          {
                              docs: ["An event that is thrown when a gateway signer is changed"];
                              name: "gatewaySignerChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldSigner"; type: "pubkey" },
                                      { name: "newSigner"; type: "pubkey" },
                                  ];
                                  kind: "struct";
                              };
                          },
                      ],
                      EmptyDefined,
                  >,
              >;
              recipient: PublicKey;
              status: DecodeEnum<
                  { kind: "enum"; variants: [{ name: "active" }, { name: "paused" }] },
                  DecodedHelper<
                      [
                          {
                              docs: ["An event that is thrown when a gateway fee bps is changed"];
                              name: "gatewayFeeBpsChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldFeeBps"; type: "u16" },
                                      { name: "newFeeBps"; type: "u16" },
                                  ];
                                  kind: "struct";
                              };
                          },
                          {
                              docs: [
                                  "An event that is thrown when a gateway fee recipient is changed",
                              ];
                              name: "gatewayFeeRecipientChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldFeeRecipient"; type: "pubkey" },
                                      { name: "newFeeRecipient"; type: "pubkey" },
                                  ];
                                  kind: "struct";
                              };
                          },
                          {
                              docs: ["An event that is thrown when a gateway signer is changed"];
                              name: "gatewaySignerChanged";
                              type: {
                                  fields: [
                                      { name: "gateway"; type: "pubkey" },
                                      { name: "oldSigner"; type: "pubkey" },
                                      { name: "newSigner"; type: "pubkey" },
                                  ];
                                  kind: "struct";
                              };
                          },
                      ],
                      EmptyDefined,
                  >,
              >;
              totalPaid: BN;
              updatedAt: BN;
              userPayment: PublicKey;
          }
          | null,
      >

      The payment policy account data or null if not found

    • Gets a Payment Policy PDA for the specified user payment and policy ID.

      Parameters

      • userPayment: PublicKey

        Public key of the user's payment PDA

      • policyId: number

        Unique identifier for the policy within the user's account

      Returns PdaResult

      PdaResult containing the PDA address and bump

    • Gets the Payments Delegate PDA used for token delegation.

      Returns PdaResult

      PdaResult containing the PDA address and bump

    • Fetches the program configuration account.

      Parameters

      • configAddress: PublicKey

        Public key of the program config account

      Returns Promise<
          | {
              admin: PublicKey;
              bump: number;
              deprecated: number;
              emergencyPause: boolean;
              feeRecipient: PublicKey;
              padding: number[];
              protocolFeeBps: number;
          }
          | null,
      >

      The program configuration data or null if not found

    • Fetches a specific referral account by its address.

      Parameters

      • referralAccountAddress: PublicKey

        Public key of the referral account

      Returns Promise<
          | {
              bump: number;
              createdAt: BN;
              gateway: PublicKey;
              owner: PublicKey;
              padding: BN[];
              paddingBump: number[];
              paddingCode: number[];
              referralCode: number[];
              referrer: PublicKey;
              totalEarned: BN;
          }
          | null,
      >

      The referral account data or null if not found

    • Fetches a referral account by gateway and referral code.

      Parameters

      • gateway: PublicKey

        Public key of the gateway

      • code: string

        6-character alphanumeric referral code

      Returns Promise<
          | {
              bump: number;
              createdAt: BN;
              gateway: PublicKey;
              owner: PublicKey;
              padding: BN[];
              paddingBump: number[];
              paddingCode: number[];
              referralCode: number[];
              referrer: PublicKey;
              totalEarned: BN;
          }
          | null,
      >

      The referral account data or null if not found

    • Fetches a specific referral account by the owner's public key and gateway. This is a convenience method that finds the referral account for an owner within a specific gateway.

      Parameters

      • gateway: PublicKey

        Public key of the gateway

      • owner: PublicKey

        Public key of the referral account owner

      Returns Promise<
          | {
              bump: number;
              createdAt: BN;
              gateway: PublicKey;
              owner: PublicKey;
              padding: BN[];
              paddingBump: number[];
              paddingCode: number[];
              referralCode: number[];
              referrer: PublicKey;
              totalEarned: BN;
          }
          | null,
      >

      The referral account data or null if not found

    • Builds the referral chain for a given user and gateway. This method traverses the referral chain up to 3 levels deep. We replace the default PublicKey by null here!

      Parameters

      • user: PublicKey

        Public key of the user to find the referral chain for

      • gateway: PublicKey

        Public key of the gateway

      Returns Promise<(PublicKey | null)[]>

      Array of referral account addresses [L1, L2, L3] (may contain nulls)

    • Gets a Referral Account PDA for the specified gateway and referral code.

      Parameters

      • gateway: PublicKey

        Public key of the gateway

      • referralCode: Buffer

        6-byte buffer of the referral code

      Returns PdaResult

      PdaResult containing the PDA address and bump

    • Fetches a specific user payment account by its address.

      Parameters

      • userPaymentAddress: PublicKey

        Public key of the user payment account

      Returns Promise<
          | {
              activePoliciesCount: number;
              bump: number;
              createdAt: BN;
              createdPoliciesCount: number;
              isActive: boolean;
              owner: PublicKey;
              padding: number[];
              tokenAccount: PublicKey;
              tokenMint: PublicKey;
              updatedAt: BN;
          }
          | null,
      >

      The user payment account data or null if not found

    • Gets a User Payment PDA for the specified user and token mint.

      Parameters

      • user: PublicKey

        Public key of the user

      • tokenMint: PublicKey

        Public key of the token mint

      Returns PdaResult

      PdaResult containing the PDA address and bump

    • Initializes the Tributary protocol by creating the program configuration account. This is a one-time setup that must be performed by the protocol admin.

      Parameters

      • admin: PublicKey

        Public key of the protocol administrator

      Returns Promise<TransactionInstruction>

      Transaction instruction to initialize the protocol

    • Updates the custom protocol fee settings for a payment gateway. Only the protocol admin can modify these settings. This allows setting a gateway-specific protocol fee that overrides the global default.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      • useCustomProtocolFee: boolean

        Whether to use custom protocol fee (true) or global default (false)

      • customProtocolFeeBps: number

        Custom protocol fee in basis points (0-10000). Only used if useCustomProtocolFee is true.

      Returns Promise<TransactionInstruction>

      Transaction instruction to update gateway protocol fee settings

    • Updates the referral settings for a payment gateway. Only the gateway authority can update these settings.

      Parameters

      • gatewayAuthority: PublicKey

        Public key of the gateway authority

      • featureFlags: number

        Bit flags to enable/disable features (bit 0 = referral enabled)

      • referralAllocationBps: number

        Basis points of gateway fee allocated to referral rewards (0-2500)

      • referralTiersBps: [number, number, number]

        Array of 3 values [L1, L2, L3] summing to 10000 bps

      Returns Promise<TransactionInstruction>

      Transaction instruction to update gateway referral settings

    • Updates the wallet used by the SDK instance. Useful for changing the signer without creating a new SDK instance.

      Parameters

      • wallet: any

        New wallet to use for signing transactions

      Returns Promise<void>

    • Validates a referral code format. Referral codes must be exactly 6 alphanumeric characters.

      Parameters

      • code: string

        The referral code to validate

      Returns boolean

      true if valid, false otherwise