Sponsor fees & rent on Solana

Fees and rent are a significant barrier to entry for new users of your app. Sponsor fees and rent to enable users to transact without holding SOL.

How it works

When you request gas sponsorship for a transaction using a configured policy, the policy engine will determine if that transaction is eligible for sponsorship. If eligible, Gas Manager will pay for the fees and rent upfront when the user sends the transaction. Gas Manager will make a note of the sponsored cost and add it to your monthly bill.

  • Fees: the cost of executing transactions
  • Rent: the minimum payment to store data onchain
    • Rent sponsorship is supported for createAccount and createAssociatedTokenAccount. If you need support for custom programs, contact [email protected].

Prerequisites

  • API key from your dashboard
  • Smart Wallets for Solana set up in your project if you want to enable sign up/login for creation of wallets
  • A sponsorship policy to cover fees and/or rent: create a policy

Implementation

Required SDK version: ^v4.59.1

Global sponsorship

To apply a sponsorship policy to all transactions sent by the Solana wallet provider, you can configure fee and rent sponsorship by passing a policyId into your Solana config. Replace the API key and Policy Id with your keys from the dashboard. This setup applies sponsorship to all Solana transactions sent from wallets created with this configuration (e.g. this will be applied to usage of the useSolana… hooks).

config.ts
1import { cookieStorage, createConfig } from "@account-kit/react";
2import { Connection } from "@solana/web3.js";
3
4createConfig({
5 ...otherConfig,
6 solana: {
7 connection: new Connection(
8 "https://solana-devnet.g.alchemy.com/v2/<API_KEY>",
9 {
10 wsEndpoint: "wss://api.devnet.solana.com",
11 commitment: "confirmed",
12 }
13 ),
14 policyId: "<PolicyId>"
15 }
16}

Per transaction sponsorship

Alternatively, to apply sponsorship conditionally for each transaction, you can pass a policyId to the useSolanaTransaction hook.

sponsor-solana-gas.tsx
1import { useSolanaTransaction } from "@account-kit/react";
2import { Connection, PublicKey, SystemProgram } from "@solana/web3.js";
3
4function MyComponent() {
5 const policyId = "<YourPolicyId>";
6
7 const { sendTransaction, signer } = useSolanaTransaction({
8 policyId,
9 });
10
11 if (!signer) {
12 return <div>Loading signer...</div>;
13 }
14
15 return (
16 <button
17 onClick={() =>
18 sendTransaction({
19 transfer: {
20 toAddress: "<ToAddress>",
21 amount: 1000000,
22 },
23 })
24 }
25 >
26 Send Sponsored Transaction
27 </button>
28 );
29}

Congrats! You’re now creating smart wallets on Solana with social login and sending sponsored transactions to create a zero-friction experience from sign-up to transaction.