JavaScript SDK
Install
npm i @unclaimedsol/spl-burn-close-sdk
Quick start
import { Connection, Keypair } from "@solana/web3.js";
import {
buildBurnAndCloseTransactions,
PROGRAM_ID,
} from "@unclaimedsol/spl-burn-close-sdk";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const keypair = Keypair.fromSecretKey(/* Uint8Array */);
const user = keypair.publicKey;
// You can get easily obtain pairs using getTokenAccountsByOwner method
const pairs = [{ mint: new PublicKey("MINT_1"), ata: new PublicKey("ATA_1") }];
const txs = await buildBurnAndCloseTransactions(
connection,
PROGRAM_ID,
user,
pairs
);
for (const tx of txs) {
tx.partialSign(keypair);
const sig = await connection.sendRawTransaction(tx.serialize());
let latestBlockhash = await connection.getLatestBlockhash(
connection.commitment
);
await connection.confirmTransaction({
signature: sig,
blockhash: latestBlockhash.blockhash,
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
});
console.log("✅ Sent:", sig);
}
NPM: You can view more details about the SDK on
NPM.