Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 3.09 KB

File metadata and controls

61 lines (41 loc) · 3.09 KB
title Sponsor fees & rent on Solana
description How to sponsor fees & rent on Solana
slug wallets/transactions/solana/sponsor-gas

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 determines if that transaction is eligible for sponsorship. If eligible, the Gas Manager pays for the fees and rent upfront when the transaction is sent. The Gas Manager records the sponsored cost and adds 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 wallets@alchemy.com.

Prerequisites

Solana sponsorship is behind a feature flag. Before implementing, make sure your app is enabled for Solana sponsorship and has Solana chains enabled.
  1. Request access to the Solana sponsorship feature flag
    • Solana sponsorship is currently available for enterprise customers.
    • If your app is not enabled yet, contact wallets@alchemy.com to request access.
  2. Enable Solana chains on your app
    • In your Alchemy dashboard, verify that Solana chains are enabled for the app you are using.
  • 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

### Prepare a serialized Solana transaction
Here’s an example of creating a serialized transfer transaction using JavaScript:

<Markdown src="api-prepare.mdx" />

### Request sponsorship for the serialized transaction

To sponsor fees and rent on Solana, 1) set the `payerKey` field of the transaction to the feePayer wallet that pays for the gas, and 2) the feePayer wallet must sign the transaction.

Get the `feePayer` address and the feePayer signature through [`alchemy_requestFeePayer`](/docs/reference/alchemy-requestfeepayer) using your gas policy ID and the serialized transaction. The Gas Manager updates the `feePayer` and adds the signature to the `serializedTransaction` if and only if the transaction satisfies the rules defined in your policy.

<Markdown src="api-request.mdx" />

### Sign and broadcast the transaction

Here is an example of signing and broadcasting a transaction using JavaScript:

<Markdown src="api-sign.mdx" />