Skip to main content

Rent sponsorship is a built-in feature of the Light SDK’s that sponsors rent-exemption for all account types to reduce creation cost. This is dealt with under the hood in a way that doesn’t disrupt the UX of what your users are used to with SPL-token.Rent-exemption: paid by a rent sponsor PDA.Top-ups: paid by the fee payer.The feePayer on the transaction bumps a small virtual rent balance (766 lamports by default) on each write to keep the account active (hot balance). Set your application as the fee payer so users never interact with SOL.Hot-Cold Lifecycle of Accounts.Accounts get auto-compressed (cold balance) when the virtual rent balance goes below a threshold (eg 24h without write bump). The cold account’s state is cryptographically preserved on the Solana ledger. Users only interact with hot accounts and load the cold balance in-flight when using the account again.
Account lifecycle
Account lifecycle

How to use Sponsored Rent Top-Ups for Accounts and Transfers

To sponsor rent top-ups for your users, set the payer parameter to the sponsor’s public key when calling createTransferInterfaceInstructions (TypeScript) or building a TransferInterface instruction (Rust). The sponsor pays SOL for any rent top-ups while the user only signs to authorize the transfer.
You can set the payer to any signing account on any Light Token transaction.
import { Keypair, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
    createAtaInterface,
    createLightTokenTransferInstruction,
    getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";
import { PublicKey } from "@solana/web3.js";

const rpc = createRpc();

// Top-Up Sponsor: your application server, pays SOL for rent top-ups
const sponsor: Keypair = /* your server keypair */;

// User: only signs to authorize the transfer
const sender: Keypair = /* user's keypair */;
const recipient = new PublicKey(/* recipient address */);
const mint = new PublicKey(/* e.g. USDC mint */);

(async function () {
    const senderAta = getAssociatedTokenAddressInterface(mint, sender.publicKey);
    const recipientAta = getAssociatedTokenAddressInterface(mint, recipient);

    // Create recipient associated token account if it doesn't exist
    await createAtaInterface(rpc, sponsor, mint, recipient);

    const ix = createLightTokenTransferInstruction(
        senderAta,
        recipientAta,
        sender.publicKey,
        500_000,
        sponsor.publicKey, 
    );

    const tx = new Transaction().add(ix);
    const sig = await sendAndConfirmTransaction(rpc, tx, [sponsor, sender]);

    console.log("Tx:", sig);
})();

Didn’t find what you were looking for?

Reach out! Telegram | email | Discord