Creates a new Tributary SDK instance.
Solana RPC connection to use for all operations
Wallet containing the keypair for signing transactions
Solana RPC connection
Anchor program instance for the Recurring Payments contract
Public key of the deployed program
Anchor provider with wallet and connection
Changes the gateway fee in basis points for a payment gateway. Only the gateway authority can change the fee.
Public key of the gateway authority
New gateway fee in basis points (0-10000)
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.
Public key of the gateway authority
Public key of the new fee recipient
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.
Public key of the current gateway authority
Public key of the new signer
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.
Public key of the token mint
ID of the policy to modify
New status for the policy
Transaction instruction to change the policy status
Creates a milestone payment policy with full setup including ATAs, user payment account, and token approvals. Use getCreateMilestonePolicyInstruction() for just the instruction without setup.
Public key of the token mint
Public key of the payment recipient
Public key of the payment gateway
Array of amounts for each milestone (up to 4)
Array of timestamps when each milestone is due
Bitmap: bit0=check due date, bit1=gateway signer, bit2=owner signer, bit3=recipient signer. Bits 1-3 mutually exclusive.
Memo bytes for the payment policy
OptionalapprovalAmount: BNOptional specific approval amount (calculated automatically if not provided)
OptionalexecuteImmediately: booleanWhether to execute the first milestone immediately if due
OptionalreferralCode: stringArray 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.
Public key of the token mint
Public key of the payment recipient
Public key of the payment gateway
Maximum amount allowed per period
Maximum amount that can be claimed in one go
Length of each period in seconds
Memo bytes for the payment policy
OptionalapprovalAmount: BNOptional specific approval amount (calculated automatically if not provided)
OptionalreferralCode: stringArray 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.
Public key that controls the gateway
Fee in basis points (100 bps = 1%) charged by the gateway
Public key that receives gateway fees
Display name for the gateway (max 32 characters)
Website URL for the gateway (max 64 characters)
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).
Public key of the gateway this referral account belongs to
6-character alphanumeric referral code for this user
Optionalreferrer: PublicKeyOptional public key of the user who referred this user (L1 referrer)
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.
Public key of the token to be paid
Public key that receives the payments
Public key of the gateway that will execute payments
Amount to pay per interval (in smallest token units)
Whether the subscription should auto-renew
Maximum number of renewals allowed (null for unlimited)
How often payments should occur
Memo bytes to include with payments (max 64 bytes)
OptionalstartTime: BN | nullWhen the first payment should occur (defaults to now)
OptionalapprovalAmount: BNAmount to approve for token delegation (calculated automatically if not provided)
OptionalexecuteImmediately: booleanWhether to execute the first payment immediately
OptionalreferralCode: stringOptional 6-character referral code to associate with this subscription
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.
Public key of the token mint for payments
Transaction instruction to create the user payment account
Deletes a payment gateway. Only the protocol admin can delete gateways.
Public key of the gateway authority
Transaction instruction to delete the payment gateway
Deletes a payment policy permanently. Only the policy owner can delete their policies.
Public key of the token mint
ID of the policy to delete
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.
Public key of the payment policy account
OptionalpaymentAmount: BNAmount to pay (optional for subscription/milestone, required for pay-as-you-go)
Optionalrecipient: PublicKeyPublic key of the payment recipient (optional if in policy)
OptionaltokenMint: PublicKeyPublic key of the token mint (optional if in policy)
Optionalgateway: PublicKeyPublic key of the payment gateway (optional if in policy)
Optionaluser: PublicKeyPublic key of the payment user (optional if in policy)
Array of transaction instructions including ATA creation and payment execution
Retrieves all payment gateways in the protocol.
Array of payment gateway accounts with their public keys
Retrieves all payment policies in the protocol.
Array of payment policy accounts with their public keys
Retrieves all user payment accounts in the protocol.
Array of user payment accounts with their public keys
Retrieves all user payment accounts owned by a specific user.
Public key of the user
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.
Public key of the token to be paid
Public key that receives the payments
Public key of the gateway that will execute payments
Array of amounts for each milestone (up to 4)
Array of timestamps when each milestone is due
Bitmap: bit0=check due date, bit1=gateway signer, bit2=owner signer, bit3=recipient signer. Bits 1-3 mutually exclusive.
Memo bytes to include with payments (max 64 bytes)
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.
Public key of the token to be paid
Public key that receives the payments
Public key of the gateway that will execute payments
Maximum amount allowed per period
Maximum amount that can be claimed in a single payment
Length of each period in seconds
Memo bytes to include with payments (max 64 bytes)
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.
Public key of the token to be paid
Public key that receives the payments
Public key of the gateway that will execute payments
Amount to pay per interval (in smallest token units)
Whether the subscription should auto-renew
Maximum number of renewals allowed (null for unlimited)
How often payments should occur
Memo bytes to include with payments (max 64 bytes)
OptionalstartTime: BN | nullWhen the first payment should occur (defaults to now)
Transaction instruction to create the subscription payment policy
Gets a Payment Gateway PDA for the specified authority.
Public key of the gateway authority
PdaResult containing the PDA address and bump
Fetches a specific payment gateway account by its address.
Public key of the payment gateway account
The payment gateway account data or null if not found
Retrieves all payment policies executed by the specified gateway.
Public key of the payment gateway
Array of payment policies executed by the gateway
Retrieves all payment policies where the specified user is the recipient.
Public key of the payment recipient
Array of payment policies where the user is the recipient
Retrieves all payment policies where the specified user is the payer.
Public key of the payment user
Array of payment policies where the user is the payer
Retrieves all payment policies belonging to the specified user payment account.
Public key of the user payment PDA
Array of payment policies for the user payment account
Fetches a specific payment policy account by its address.
Public key of the payment policy account
The payment policy account data or null if not found
Gets a Payment Policy PDA for the specified user payment and policy ID.
Public key of the user's payment PDA
Unique identifier for the policy within the user's account
PdaResult containing the PDA address and bump
Gets the Payments Delegate PDA used for token delegation.
PdaResult containing the PDA address and bump
Fetches the program configuration account.
Public key of the program config account
The program configuration data or null if not found
Fetches a specific referral account by its address.
Public key of the referral account
The referral account data or null if not found
Fetches a referral account by gateway and referral code.
Public key of the gateway
6-character alphanumeric referral code
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.
Public key of the gateway
Public key of the referral account owner
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!
Public key of the user to find the referral chain for
Public key of the gateway
Array of referral account addresses [L1, L2, L3] (may contain nulls)
Gets a Referral Account PDA for the specified gateway and referral code.
Public key of the gateway
6-byte buffer of the referral code
PdaResult containing the PDA address and bump
Fetches a specific user payment account by its address.
Public key of the user payment account
The user payment account data or null if not found
Gets a User Payment PDA for the specified user and token mint.
Public key of the user
Public key of the token mint
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.
Public key of the protocol administrator
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.
Public key of the gateway authority
Whether to use custom protocol fee (true) or global default (false)
Custom protocol fee in basis points (0-10000). Only used if useCustomProtocolFee is true.
Transaction instruction to update gateway protocol fee settings
Updates the referral settings for a payment gateway. Only the gateway authority can update these settings.
Public key of the gateway authority
Bit flags to enable/disable features (bit 0 = referral enabled)
Basis points of gateway fee allocated to referral rewards (0-2500)
Array of 3 values [L1, L2, L3] summing to 10000 bps
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.
New wallet to use for signing transactions
Validates a referral code format. Referral codes must be exactly 6 alphanumeric characters.
The referral code to validate
true if valid, false otherwise
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.
Example