Shelby USD Sponsorship
Shelby is a storage protocol that uses Aptos as its coordination layer. Certain Shelby operations, such as registering blobs, require payment in ShelbyUSD (in addition to the usual gas costs in APT). Normally, your users would need to hold and spend ShelbyUSD to perform these operations.
With ShelbyUSD sponsorship enabled, your gas station can cover these ShelbyUSD costs on behalf of your users, providing a smoother user experience where users don’t need to hold any assets at all.
How It Works
- Standard Gas Sponsorship: Your gas station pays APT gas fees for transactions.
- ShelbyUSD Sponsorship: Your gas station additionally covers ShelbyUSD storage costs.
When you enable ShelbyUSD sponsorship:
- The gas station fee payer account will be funded with ShelbyUSD in addition to APT.
- Your users call Shelby functions with the
_with_sponsorsuffix (the Shelby SDK handles this automatically). - The gas station signs as both a fee payer (for APT gas) and a secondary signer (for ShelbyUSD sponsorship).
How to create a gas station with ShelbyUSD sponsorship
The option to enable ShelbyUSD sponsorship only appears when you’re configuring a gas station for the Shelby contract on shelbynet or testnet. When creating a gas station, input the contract address.
Shelbynet
| Address Type | Address |
|---|---|
| Contract address | 0x85fdb9a176ab8ef1d9d9c1b60d60b3924f0800ac1de1cc2085fb0b8bb4988e6a |
| ShelbyUSD FA metadata address | 0x1b18363a9f1fe5e6ebf247daba5cc1c18052bb232efdc4c50f556053922d98e1 |
Testnet
| Address Type | Address |
|---|---|
| Contract address | 0x85fdb9a176ab8ef1d9d9c1b60d60b3924f0800ac1de1cc2085fb0b8bb4988e6a |
| ShelbyUSD FA metadata address | 0x1b18363a9f1fe5e6ebf247daba5cc1c18052bb232efdc4c50f556053922d98e1 |
Once you have created the gas station, record the fee payer address and API key.
ShelbyUSD sponsorship currently does not have built-in spending limits for ShelbyUSD itself. Any user who submits a valid transaction matching your rules can consume ShelbyUSD from your fee payer account. ShelbyUSD based limits (windowed and per txn) are on the roadmap.
Client Integration
Using the Shelby SDK (Recommended)
The @shelby-protocol/sdk has built-in support for ShelbyUSD sponsorship. When you pass usdSponsor to the SDK, it automatically:
- Uses the
_with_sponsorvariants of entry functions (e.g.,register_blob_with_sponsorinstead ofregister_blob). - Includes your gas station’s fee payer as a secondary signer in the transaction.
- Routes the transaction through the gas station for co-signing via the transaction submitter plugin.
Install the required packages:
pnpm add @shelby-protocol/sdk @aptos-labs/gas-station-client @aptos-labs/ts-sdkSet up the gas station client and Shelby blob client:
import { ShelbyBlobClient } from "@shelby-protocol/sdk";
import { GasStationClient, GasStationTransactionSubmitter } from "@aptos-labs/gas-station-client";
import { AccountAddress, Network } from "@aptos-labs/ts-sdk";
// 1. Create a gas station client with your API key.
const gasStationClient = new GasStationClient({
network: Network.SHELBYNET,
apiKey: "YOUR_GAS_STATION_API_KEY",
});
// 2. Wrap it in a transaction submitter plugin.
const transactionSubmitter = new GasStationTransactionSubmitter(gasStationClient);
// 3. Create a ShelbyBlobClient with ShelbyUSD sponsorship enabled.
const blobClient = new ShelbyBlobClient(
{
network: Network.SHELBYNET,
aptos: {
pluginSettings: {
TRANSACTION_SUBMITTER: transactionSubmitter,
},
},
},
{
// The feePayerAddress is your gas station's fee payer, which you can find on the
// gas station overview page.
usdSponsor: {
feePayerAddress: AccountAddress.from("0x<your-fee-payer-address>"),
},
},
);From here, all blob operations automatically use the sponsored variants:
// The SDK calls register_blob_with_sponsor under the hood and routes
// the transaction through the gas station for co-signing.
await blobClient.upload({
blobData: myData,
signer: userAccount,
blobName: "example.txt",
expirationMicros: Date.now() * 1000 + 86400_000_000,
});Details
When ShelbyUSD sponsorship is enabled, additional functions become available that end with _with_sponsor. These are special variants that allow the gas station to authorize ShelbyUSD payments on behalf of the user.
For example:
register_blob→register_blob_with_sponsorregister_multiple_blobs→register_multiple_blobs_with_sponsorincrease_expiration_time→increase_expiration_time_with_sponsor
You can use both types of sponsorship simultaneously so your users don’t need to hold any tokens at all.
| APT Sponsorship | ShelbyUSD Sponsorship | |
|---|---|---|
| What it pays | Gas fees (APT) | Storage fees (ShelbyUSD) |
| How to enable | build: { withFeePayer: true } | usdSponsor: { feePayerAddress } |
| Entry functions used | Standard (register_blob) | _with_sponsor variants |
When both are enabled, the gas station signs as both the fee payer (for APT gas) and a secondary signer (for costs in ShelbyUSD).