PaymentsAdvanced Payments

Spend Permissions

Solana's Token Programs support delegation—granting another account permission to transfer tokens from your token account up to a specified limit. This enables use cases like automated payments, escrow services, and third-party payment processing without giving up custody of your funds.

How Delegation Works

When you approve a delegate, you're authorizing a specific account to transfer tokens on your behalf:

  • Owner retains custody: You still own the tokens and can transfer or revoke at any time
  • Capped spending: The delegate can only transfer up to the approved amount
  • Single delegate per account: Each token account can only have one active delegate
  • New approval replaces old: Approving a new delegate automatically revokes the previous one

Delegation is non-custodial. The delegate can spend tokens up to the limit, but cannot access or drain the account beyond the approved amount. The owner can revoke at any time.

Business Use Cases

Use CaseHow Delegation Helps
Payment processorsMerchant grants processor permission to settle transactions
Automated payrollTreasury approves payroll service to disburse salaries
Escrow servicesBuyer delegates to escrow agent for conditional release
Trading platformsUser approves exchange to execute trades on their behalf
Card issuanceUser approves card issuer to charge purchases to their token account

Approving a Delegate

Grant another account permission to spend tokens from your account:

import { getApproveCheckedInstruction } from "@solana-program/token";
// Approve delegate to spend up to 1,000 USDC (6 decimals)
const approveInstruction = getApproveCheckedInstruction({
source: tokenAccountAddress, // Your token account
mint: usdcMintAddress, // USDC mint
delegate: delegateAddress, // Account receiving permission
owner: ownerKeypair, // You (must sign)
amount: 1_000_000_000n, // 1,000 USDC in base units
decimals: 6
});

Parameters:

  • source: The token account granting permission
  • delegate: The account that will have spending permission
  • owner: Current owner of the token account (must sign the transaction)
  • amount: Maximum tokens the delegate can transfer
  • decimals: Token decimals for validation (prevents decimal errors)

Revoking a Delegate

Remove all spending permissions from the current delegate:

import { getRevokeInstruction } from "@solana-program/token";
const revokeInstruction = getRevokeInstruction({
source: tokenAccountAddress, // Your token account
owner: ownerKeypair // You (must sign)
});

Revoke removes all delegate permissions—there's no partial revoke. If you need to reduce the limit, approve the same delegate with a lower amount.

Checking Delegation Status

Query a token account to see its current delegate and remaining allowance:

import { fetchToken } from "@solana-program/token";
const tokenAccount = await fetchToken(rpc, tokenAccountAddress);
if (tokenAccount.data.delegate) {
console.log("Delegate:", tokenAccount.data.delegate);
console.log("Remaining allowance:", tokenAccount.data.delegatedAmount);
} else {
console.log("No delegate set");
}

Transferring as a Delegate

When acting as the delegate, use a standard transfer but sign with the delegate keypair instead of the owner:

Transfer as Delegate
import { getTransferCheckedInstruction } from "@solana-program/token";
const transferInstruction = getTransferCheckedInstruction({
source: ownerTokenAccount, // The account you have permission to spend from
mint: usdcMintAddress,
destination: recipientTokenAccount,
authority: delegateKeypair, // You (the delegate) sign, not the owner
amount: 100_000_000n, // 100 USDC
decimals: 6
});

The transfer will succeed if:

  • The source account has sufficient balance
  • The delegate signs the transaction

Each transfer reduces the remaining allowance. When the allowance reaches zero, the delegate can no longer transfer tokens.

Security Considerations

For account owners:

  • Only approve trusted delegates
  • Set the minimum necessary spending limit
  • Revoke delegations when no longer needed
  • Monitor your accounts for unexpected transfers

For service providers (delegates):

  • Clearly communicate the requested spending limit to users
  • Implement proper key management for your delegate account
  • Track allowance consumption to request re-approval before limits are exhausted

Delegation vs. Custody

AspectDelegationFull Custody
Token ownershipUser retainsUser transfers to custodian
Spending controlCapped at approved amountFull access to transferred funds
RevocationInstant, by ownerRequires custodian cooperation
Risk exposureLimited to approved amountEntire balance
Trust requiredLimitedHigh

Delegation provides a middle ground—enabling automated payments while limiting risk exposure to the approved amount.

Is this page helpful?

सामग्री तालिका

पृष्ठ संपादित करें

द्वारा प्रबंधित

© 2026 सोलाना फाउंडेशन। सर्वाधिकार सुरक्षित।
जुड़े रहें