Use this file to discover all available pages before exploring further.
On Solana, accounts must hold a rent-exempt balance (lamports) to exist. When you close an empty token account, those lamports are returned to the destination you specify. If you set outcomeAccountRentRecipient when requesting an order, retrieve that value from your stored order params and reuse it as the close destination. Otherwise, choose any destination (typically the user’s wallet).Closing a token account is a standard SPL Token action. DFlow does not provide a dedicated endpoint for this.
1
Choose the rent destination
Decide where the reclaimed rent should go. If your app set
outcomeAccountRentRecipient when creating the order, use that address.
Select a rent destination
import "dotenv/config";import { createBurnInstruction, createCloseAccountInstruction, getAccount,} from "@solana/spl-token";import { Connection, Keypair, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";import bs58 from "bs58";const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";const keypair = Keypair.fromSecretKey( bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? ""));const userPublicKey = keypair.publicKey.toBase58();// Optional: reuse the address you set when creating the order.// If you did not set one, default to the user's wallet.const outcomeAccountRentRecipient = storedOrderParams?.outcomeAccountRentRecipient ?? null;const rentDestination = outcomeAccountRentRecipient ?? userPublicKey;
2
Burn remaining tokens and close the account
A token account must be empty to close. If it still has a balance, burn the
remaining outcome tokens and then close the account to reclaim rent.