Fees and rent are a significant barrier to entry for new users of your app. Sponsor them to let users transact without holding SOL.
- Works with any Solana wallet. Check out Solana Wallet APIs
- No need to manage SOL. Fees and rent are sponsored and added to your bill.
When you request sponsorship for a transaction using a configured policy, the policy engine determines if that transaction is eligible. If eligible, the Gas Manager sets the fee payer, signs the transaction, and returns the updated serialized transaction. The sponsored cost is added to your monthly bill.
- Fees: the cost of executing transactions. Alchemy's fee payer replaces yours on every sponsored transaction.
- Rent: the minimum payment to store data onchain.
- Top-level rent sponsorship: on every sponsored transaction, any top-level
SystemProgram.createAccountand Associated Token ProgramCreate/CreateIdempotentinstructions are rewritten so the paymaster funds them directly. You do not need to opt in — this happens for all requests. - CPI rent sponsorship: for account creation that happens inside a cross-program invocation (CPI), opt in per request with
prefundRent: true. See CPI rent prefunding below — this mode adds a hard requirement onpayerKey. - We do not support sponsoring rent for
SystemProgram.createAccountWithSeed.
- Top-level rent sponsorship: on every sponsored transaction, any top-level
- API key from your dashboard
- A sponsorship policy to cover fees and/or rent: create a policy
Here’s an example of creating a serialized transfer transaction using JavaScript:
import * as solanaWeb3 from "@solana/web3.js";
import { connection, keypair } from "./config.ts";
const instructions = [
solanaWeb3.SystemProgram.transfer({
fromPubkey: keypair.publicKey,
toPubkey: keypair.publicKey,
lamports: 5,
}),
];
const { blockhash } = await connection.getLatestBlockhash();
const message = new solanaWeb3.TransactionMessage({
payerKey: new solanaWeb3.PublicKey(
// Placeholder: Set this to an address different than any other address included in the tx, will be replaced by alchemy's feePayer
"Amh6quo1FcmL16Qmzdugzjq3Lv1zXzTW7ktswyLDzits",
),
recentBlockhash: blockhash,
instructions,
}).compileToV0Message();
const transaction = new solanaWeb3.VersionedTransaction(message);
export const serializedTransaction = Buffer.from(transaction.serialize()).toString(
"base64",
);To sponsor fees on Solana, 1) set the payerKey field of the transaction, and 2) call alchemy_requestFeePayer.
alchemy_requestFeePayer updates the feePayer and adds the fee-payer signature if the transaction satisfies the rules defined in your policy.
What to put at payerKey depends on the request:
- Default (fees + top-level rent): any placeholder address that is not otherwise referenced in the transaction. The paymaster replaces it as the fee payer, and any top-level
createAccount/createAssociatedTokenAccountinstructions are rewritten so the paymaster funds them — the identity of the placeholder does not affect sponsorship. - With
prefundRent: true: the user's wallet, specifically the account your program's CPI will debit for rent. See CPI rent prefunding for the full contract.
import {
ALCHEMY_API_KEY,
POLICY_ID,
RPC_URL,
type AlchemyFeePayerResponse,
} from "./config.ts";
import { serializedTransaction } from "./prepare.ts";
const response = await fetch(RPC_URL, {
method: "POST",
headers: {
accept: "application/json",
"content-type": "application/json",
},
body: JSON.stringify({
id: 1,
jsonrpc: "2.0",
method: "alchemy_requestFeePayer",
params: [{ policyId: POLICY_ID, serializedTransaction }],
}),
});
const data = (await response.json()) as AlchemyFeePayerResponse;
const serializedSponsoredTransaction = data.result?.serializedTransaction;Here is an example of signing and broadcasting a transaction using JavaScript:
import { VersionedTransaction } from "@solana/web3.js";
import { connection, keypair } from "./config.ts";
import { sponsoredSerializedTransaction } from "./request.ts";
const tx = VersionedTransaction.deserialize(
Buffer.from(sponsoredSerializedTransaction, "base64"),
);
tx.sign([keypair]);
const signature = await connection.sendRawTransaction(tx.serialize(), {
// Explicit so preflight cannot fall back to the node default of `finalized`.
preflightCommitment: "confirmed",
});Use prefundRent: true to opt into cross-program invocation (CPI) rent prefunding when a transaction may create accounts through CPI.
This feature is allowlisted. Contact support@alchemy.com to request access.
{
"policyId": "<POLICY_ID>",
"serializedTransaction": "<base64-serialized-tx>",
"prefundRent": true
}When prefundRent is enabled, the service simulates the sponsored transaction to estimate any rent that may be needed for CPI-driven account creation. If needed, it adds a SystemProgram.transfer from the paymaster to the user's wallet — signaled by being the original payerKey on the submitted transaction, before the paymaster replaces it as fee payer — so the user's wallet holds enough SOL to cover the CPI's account creation.
When a prefund simulation runs, the response includes prefundLamports and simulationSlot alongside the normal fee sponsorship fields. Both are omitted when no simulation ran — either because prefundRent was not requested or because the fee payer was replaced rather than injected, leaving no user wallet to top up.
We support sponsoring rent for inner SystemProgram.createAccount calls. SystemProgram.createAccountWithSeed is not sponsored today.
payerKeyMUST be set to the user's wallet — the same account your program's CPI will debit for rent. This is different from fee and top-level rent sponsorship, wherepayerKeycan be any placeholder address. WithprefundRent: true, the service targetspayerKeyby position: it transfers SOL to whatever account sits there, and only detects innercreateAccountcalls funded by that same account. IfpayerKeyis a placeholder (or any account other than the CPI funder), prefunding silently misses and the transaction will fail on-chain for lack of rent.- Set
maxSpendPerTxnUsdon every policy used withprefundRent. The request is rejected if the policy does not have this cap. - Additional access is required for composed account creation and for topping up rent when an account grows. Contact support@alchemy.com to request access.
- Enable
prefundRentonly for flows that may create accounts through CPI. - Submit the returned transaction promptly from your backend after collecting signatures.
- When sending quick subsequent transactions that depend on each other, call
sendTransactionwithpreflightCommitment: "confirmed", or withskipPreflight: trueto skip preflight entirely. Preflight otherwise falls back tofinalized, which trails the chain by roughly 13 seconds, so it will fail on state the earlier transaction just wrote.
- Only rent is sponsored. The service rejects programs that deposit additional fees into the account they create, such as Metaplex Token Metadata creation, which includes a 0.01 SOL fee.
- Simulation is not the same as execution. Account state can change between sponsorship and submission, and programs can take different CPI paths at execution time.
- If execution needs more lamports than the simulation predicted, the transaction will fail. If execution needs less, the extra SOL remains in the funded wallet and is still billed to your policy.
- Important: Only use
prefundRentfor payloads you control or can validate. If an attacker can influence the transaction or the programs it invokes, they may be able to grief your policy by causing failed or unnecessarily expensive prefunds. prefundRentis not transaction-shape-preserving. When prefunding is needed, the returned transaction includes an added top-levelSystemProgram.transferinstruction before your program flow. Programs that inspect sibling instructions or depend on exact top-level instruction ordering can behave differently or fail.- Durable nonce transactions have a simulation caveat: the service simulates a modified copy without
AdvanceNonceAccount, then returns a nonce-preserving transaction for submission.
Sponsorship for Solana v1 transactions is in beta. Contact support@alchemy.com with any questions.
When building a v1 transaction for sponsorship, use these settings and limits:
-
Compute units and loaded accounts data size: Set both limits to nonzero values in the transaction config. Both default to
0, which causes the service to reject the request. Unlike legacy and v0 transactions, v1 transactions no longer useComputeBudgetinstructions to set these limits. -
Priority fee: Set the total fee in lamports. The maximum value allowed is 10,000,000 lamports. This fee is charged once per transaction.
-
Transaction size: Stay within 4,096 bytes, including signatures, with at most 12 signatures, 64 accounts, and 64 instructions. These limits apply after the service modifies your transaction, so leave room for these additions:
- Adding the paymaster as a new signer uses one signature, one account, and 96 bytes.
- Rent prefunding adds one transfer instruction (18 bytes). If the transaction does not already reference the System Program, it also adds that account (32 bytes).
- To accommodate both additions, leave at least 146 bytes, one signature slot, two account slots, and one instruction slot available.
For comparison, legacy and v0 transactions allow 1,232 bytes. See SIMD-0296.
-
Address lookup tables: These are not supported in v1 transactions. See SIMD-0385.
-
Durable nonces: Alchemy does not sponsor v1 transactions that use durable nonces. Solana plans to remove durable nonces.
Simulate your transaction to estimate its compute-unit and loaded-accounts data size requirements, then add some headroom. See Solana's compute budget documentation.
For fee-only sponsorship, the service checks that both limits are nonzero but does not simulate the transaction or verify that the limits are sufficient. For example, a transaction that needs 200,000 compute units but requests 100,000 can receive sponsorship and still fail during execution.
Submit with preflight enabled to catch insufficient limits before the transaction lands. Preflight can reject the transaction with errors such as MaxLoadedAccountsDataSizeExceeded or ProgramFailedToComplete. Without preflight, the transaction can land and fail onchain. Repeatedly submitting transactions that fail because of invalid limits may result in Alchemy revoking your access to sponsorship.
If you use rent prefunding, the service simulates the transaction with the added prefund transfer. Your limits must cover both your instructions and that transfer. If they do not, the service rejects the request before signing; it does not increase your limits automatically.
Avoid setting limits much higher than you need. Higher limits do not increase the v1 priority fee, which is a fixed total in lamports, but they do increase the transaction cost that leaders use for scheduling. This can lower your transaction's scheduling priority. See Anza's guides on transaction costs and compute units and loaded accounts data size limits.
Sign the message in the returned serializedTransaction and place each signature in its corresponding slot. The service does not carry over signatures from the transaction you submitted; only the paymaster's signature slot is filled in the response.
If the service adds the paymaster as a new signer, the returned transaction has one more signature slot than the original.
To enable prefunding, follow the CPI rent prefunding requirements: set prefundRent: true, use the user's wallet as payerKey, and set a per-transaction spend cap on your policy.
Prefunding applies only when the service adds the paymaster as the fee payer while keeping the original payer in the transaction. If the service replaces the original payer instead, prefundRent has no effect.
When prefunding adds a transfer, it shifts instruction positions. The service rejects v1 transactions with any of the following before signing:
- An instruction that receives the Instructions sysvar.
- A secp256k1 signature verification proof.
- An Ed25519 or secp256r1 signature verification proof that references an explicit instruction index.
Self-contained Ed25519 and secp256r1 proofs, with all instruction indices set to 0xffff, are supported. These restrictions do not apply to fee-only sponsorship.