๐Ÿ“˜Read Client

The PreAuthorizedDebitReadClient component of the SDK is outlined in the interface found in our Github repo.

Instantiating a PreAuthorizedDebitReadClient

Mainnet

import { clusterApiUrl, Connection } from "@solana/web3.js";
import { PreAuthorizedDebitReadClientImpl } from "@seabed-labs/pre-authorized-debit";

// You can use any connection object you'd like, this is just an example
const connection = new Connection(clusterApiUrl("mainnet-beta"));

const readClient = PreAuthorizedDebitReadClientImpl.mainnet(connection);

Devnet

import { clusterApiUrl, Connection } from "@solana/web3.js";
import { PreAuthorizedDebitReadClientImpl } from "@seabed-labs/pre-authorized-debit";

// You can use any connection object you'd like, this is just an example
const connection = new Connection(clusterApiUrl("devnet"));

const readClient = PreAuthorizedDebitReadClientImpl.devnet(connection);

Custom

Point the read client to a custom deployment on any cluster:

Supported Methods

The read client supports the following methods:

Fetch IDL from chain

Our IDL is already available as Typescript or JSON. If you'd like to directly fetch it on-chain, you can either run the script here or just use our SDK:

This should return the IDL found here.

Derive the Smart Delegate PDA

Derive the singleton SmartDelegate account's PDA details (public key and canonical bump):

Derive the Pre-Authorization PDA

Derive a PreAuthorization account's PDA details (public key and canonical bump) for a particular pair of token account and debit authority:

Fetch the Smart Delegate account

Fetch the singleton SmartDelegate account (returns null if no account found on-chain)

Fetch a Pre Authorization account

Fetch the PreAuthorization account by providing it's public key (returns null if no account found on-chain)

Fetch it by providing the token account and debit authority instead (returns null if no account found on-chain)

Fetch all Pre-Authorizations associated with a token account

Fetch all PreAuthorization accounts associated with a particular token account (you can specify one-time, recurring, or all types):

Fetch all Pre-Authorizations associated with a debit authority

Fetch all PreAuthorization accounts associated with a particular debit authority (you can specify one-time, recurring, or all types):

Fetch maximum debit amount for a Pre-Authorization

Fetch the maximum possible amount that can be debited by the debit authority for a given pre-authorization:

Check if amount can be debited against a pre-authorization

Check whether a debit will go through given a pre-authorization pubkey (using the current solana validator time):

Check whether a debit will go through given the token account and debit authority pubkeys (using the current solana validator time):

Fetch the token program ID for a token account

Fetch the token program ID (Token or Token2022) for a given token account:

Fetch the current owner of a token account

Fetch the current delegation of a token account

Fetch the current delegate and delegated amount of a token account (returns null if no delegate or delegated amount is 0):

Fetch the current owner of a Pre-Authorization's token account

Fetch the current owner of a token account given the pre-authorization public key:

Fetch the current delegation of a Pre-Authorization's token account

Fetch the current delegate and delegated amount of a token account given the pre-authorization public key (returns null if no delegate or delegated amount is 0):

Last updated