@xyber-labs/xyber-points
v0.1.0
Published
TypeScript SDK and CLI for onchain-xyber-points Solana program
Downloads
22
Readme
@xyber-labs/xyber-points
TypeScript SDK and CLI for the onchain-xyber-points Solana program.
Program address: oxp5daG6BinG1AL2W83RQmmN8tcXJqrqy3bYprLMRV8
Installation
npm install @xyber-labs/xyber-pointsCLI
npx @xyber-labs/xyber-points@latest --help
npx @xyber-labs/xyber-points@latest initialize --help
npx @xyber-labs/xyber-points@latest mint-points --helpInitialize
Creates the program config and points mint accounts.
npx @xyber-labs/xyber-points@latest --rpc-url <RPC_URL> initialize \
--new-admin <ADMIN_PUBKEY> \
--new-minter <MINTER_PUBKEY> \
--signer-keypair <PATH_TO_KEYPAIR>Mint Points
Mints points tokens to a recipient.
npx @xyber-labs/xyber-points@latest --rpc-url <RPC_URL> mint-points \
--recipient-keypair <PATH_TO_RECIPIENT_KEYPAIR> \
--amount <AMOUNT> \
--minter-keypair <PATH_TO_MINTER_KEYPAIR>The --rpc-url flag can be replaced by the ANCHOR_PROVIDER_URL environment variable.
SDK Usage
import { OnchainXyberPointsSDK } from "@xyber-labs/xyber-points";
import { AnchorProvider, Program, BN } from "@coral-xyz/anchor";
const sdk = OnchainXyberPointsSDK.create(provider, program);
// PDA helpers
const [configPda] = sdk.getConfigPda();
const [pointsMintPda] = sdk.getPointsMintPda();
const [noncePda] = sdk.getNoncePda(recipientPublicKey);
// Get current nonce for a recipient
const nonce = await sdk.getNonce(recipientPublicKey);
// Initialize (Ix / Tx / send)
const ix = await sdk.initializeIx({ authority, newAdmin, newMinter });
const tx = await sdk.initializeTx({ authority, newAdmin, newMinter });
const sig = await sdk.initialize({ authority, newAdmin, newMinter, signers: [keypair] });
// Mint points (Ix / Tx / send)
const ix = await sdk.mintPointsIx({ authority, recipient, amount, nonce });
const tx = await sdk.mintPointsTx({ authority, recipient, amount, nonce });
const sig = await sdk.mintPoints({ authority, recipient, amount, nonce, signers: [keypair] });Each instruction follows the pattern:
<method>Ix()— returnsTransactionInstruction<method>Tx()— returnsTransaction<method>()— sends the transaction and returns the signature
