Set Up Sponsored Transactions Via the Shinami Gas Station

The Shinami Gas Station makes sponsored transactions a service builders can easily integrate with their apps.

Set Up Sponsored Transactions Via the Shinami Gas Station

Web3's requirement for wallets and tokens represents the greatest challenge to new user adoption. Sponsored transactions on Sui not only give users a frictionless experience, but open more revenue models for builders.

The pay-as-you-go blockchain model directly supports network infrastructure, but it's a huge hurdle for users who became used to the plethora of seemingly free services in the Web2 world. A potential new user may want to try a new app on Sui, only to give up once they find the need to install a wallet and buy tokens from an exchange.

Sponsored transactions let builders assume the responsibility to pay their apps' transaction fees, giving users a seamless experience. Builders opting to cover transaction fees can explore tried and true revenue models, such as hosting advertisements, unlocking trialware, and offering subscriptions.

The simplest way to get started with sponsored transactions is to leverage Shinami's Gas Station service. However, Sui lets builders sponsor transactions through techniques supporting user-initiated transactions, sponsor-initiated transactions, and through a GasData object. Builders can set up their own gas stations to monitor and control sponsored transactions.

Funding

Builders choosing to sponsor transactions need to amass enough SUI tokens to pay their users' gas fees and develop a business model to fund their operations. The amount of SUI needed will be entirely dependent on the number of transactions their apps generate. Builders can use the Sui Devnet and Testnet environments to estimate app gas fees, then project usage over time to figure out their initial capital needs. Mysten Labs is also developing a gas fee estimator, although this tool may not be available until the end of the year.

Once launched to Mainnet, builders will need to observe their transaction volume and gas fees. An app may become extremely popular, quickly burning through a builder's treasury.

Those builders using the Shinami Gas Station can take advantage of an account dashboard helping them allocate tokens and fund their apps. The dashboard shows how many gas credits a builder has available and the quantity of gas fees paid. Builders can set up different app funds within the dashboard and add tokens as needed to continue sponsoring transactions.

Creating an alternative revenue model could involve hosting ads in the app's interface, charging for premium features, or limiting free use of an app for a specific time period. Web-based ad networks have become ubiquitous and easily implementable. Charging for additional features or an app subscription may require looking into software service payment providers. A builder may also choose to sponsor free usage for a set time period, then require the user to pay their own gas fees to continue using the app.

Shinami Gas Station Setup

Builders ready to try sponsored transactions through Shinami in their apps will first need to sign up for a Shinami account (use the referral code "Gasless"). After entering the required information, builders will need to add enough SUI tokens to their account to meet the expected gas fees from their app’s users.

With the account ready to go, the Shinami Gas Station will provide a JSON-RPC API for Gas Station requests:

  • gas_sponsorTransactionBlock sponsors a gasless transaction by attaching a gas object to it and signing the sponsored transaction with the gas owner's key.
  • gas_getSponsoredTransactionBlockStatus retrieves the status of a sponsored transaction as IN_FLIGHT, INVALID, or COMPLETE.
screenshot of the Shinami Gas Station dashboard
The Shinami dashboard shows the company's services, including the Gas Station. In this view builders can monitor gas usage and add funds.

Gas Station Flow

The Shinami Gas Station is designed to give both builders and users a seamless experience. It maintains funds for specific apps and processes gas fees as they are submitted.

Here's a look at the end-to-end workflow:

1. A builder funds an app's gas station account for sponsorship via the Shinami dashboard.

2. A user interacts with an app via a connected wallet, initiating a transaction, such as minting an NFT.

3. The app constructs the transaction gaslessly under the hood (Sui's SDK includes a sponsored transaction block builder, which helps ensure proper coding).

4. The app sends the transaction to the Shinami Gas Station via gas_sponsorTransactionBlock with additional auth data verifying its gas station account has enough funds.

5. The Gas Station puts a hold on the sponsor's funds for the corresponding gas budget amount, constructs the transaction data to mint the NFT with a provisioned gas object, and signs the transaction, returning the transaction data with gas back to the app.

6. The app presents the transaction to the user and prompts for their signature via a wallet.

7. The wallet submits the transaction to the Sui network for processing, using sui_executeTransactionBlock.

diagram showing the Shinami Gas Station flow
The Shinami Gas Station flow is designed to make integrating and administering gasless transactions easy for builders.

App Integration

The Shinami documentation offers a complete TypeScript tutorial on integrating sponsored transactions with apps. It shows how to construct multiple transaction types, connect them to the Shinami Gas Station, and submit them for execution on Sui. Shinami also includes the code examples from this tutorial on GitHub.

The first step requires importing a number of libraries, including Ed25519Keypair, JsonRpcProvider, and rpcClient. The next step describes setting various parameters, such as a gas budget, Shinami Gas Station endpoints, and using Ed25519Keypair to create a keypair and signer.

The final part of the tutorial shows how to send a transaction block to Shinami for approval. The Shinami Gas Station takes this data and creates a gas object up to the budget provided, builds a new transaction with the gas object attached, and signs it with the builder's signature.

The Shinami Gas Station applies auto-budgeting and error detection when it receives a request for sponsorship. The Gas Station also manages a large, diverse pool of gas objects. This lets the Gas Station handle sponsorship of diverse transaction sizes, helps prevent gas object equivocation issues, and ensures that the gas budget allocated for a sponsored transaction is used efficiently.

Conclusion

The Shinami Gas Station can help builders get up and running with sponsored transactions by providing a convenient interface to manage funds. Builders with multiple apps will find its ability to create different funds convenient.

At Shinami, we would love to hear feedback at [email protected] from both users and builders on what we can do to facilitate great user experiences for apps on Sui. Sponsored transactions are an important means of bringing new users to Web3 and Sui.