A TypeScript SDK for interacting with Paladin Solana programs. Designed to work with any Solana wallet adapter.
npm install @paladin-bladesmith/sdk
# or
yarn add @paladin-bladesmith/sdk
- A Solana wallet adapter with sendTransaction capability
- Solana web3.js
The SDK provides a simple function-based API for interacting with Paladin protocols:
import { lockTokens } from "@paladin-bladesmith/sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const lockupForPubkey = new PublicKey("..."); // The pubkey to lock PAL for
const { signature, confirm } = await lockTokens(wallet, connection, lockupForPubkey, amount);
Lock tokens using any wallet adapter.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancelockupForPubkey
: The public key to lock PAL tokens foramount
: Number of tokens to lock (in tokens, not raw units)
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
Unlock tokens that were previously locked.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancelockupAccount
: The public key of the lockup account to unlock
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
Withdraw tokens from a previously unlocked lockup.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancelockupAccount
: The public key of the lockup account to withdraw from
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
Initialize validator staking for a specific validator. This must be called once per validator before staking.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancevalidatorPubkey
: The validator's identity public key
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
import { initializeValidatorStake } from "@paladin-bladesmith/sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const validatorIdentity = new PublicKey("..."); // Validator's identity key
const { signature, confirm } = await initializeValidatorStake(
wallet,
connection,
validatorIdentity
);
await confirm();
Stake PAL tokens to a validator.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancevalidatorIdentityPubkey
: The validator's identity public keyamount
: Number of tokens to stake (in tokens, not raw units)
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
import { validatorStakeTokens } from "@paladin-bladesmith/sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const validatorIdentity = new PublicKey("..."); // Validator's identity key
const amount = 100; // 100 PAL tokens
const { signature, confirm } = await validatorStakeTokens(
wallet,
connection,
validatorIdentity,
amount
);
await confirm();
Unstake PAL tokens from a validator.
wallet
: A wallet adapter withpublicKey
andsendTransaction
propertiesconnection
: A Solana Connection instancevalidatorPubkey
: The validator's identity public keyamount
: Number of tokens to unstake (in tokens, not raw units)
Promise that resolves to an object with:
signature
: Transaction signatureconfirm
: Function that returns a promise for transaction confirmation
import { unstakeValidatorTokens } from "@paladin-bladesmith/sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const validatorIdentity = new PublicKey("..."); // Validator's identity key
const amount = 50; // 50 PAL tokens
const { signature, confirm } = await unstakeValidatorTokens(
wallet,
connection,
validatorIdentity,
amount
);
await confirm();
Apache 2.0