Skip to main content
Soroban smart contracts involve complex resource fees for CPU, memory, and ledger footprints. Grat simplifies this by providing built-in simulation and sponsorship for all Soroban fees.

Prerequisites

  • A running Grat relay.
  • A deployed Soroban contract on Testnet.
1

Connect to the Contract

Initialize the Grat client and your contract object.
2

Build the Invocation

Build a transaction that calls a function on your contract.
3

Simulate the Transaction

Soroban transactions require resource estimates before they can be submitted. Use Grat to simulate the call and retrieve the necessary footprint data.
4

Sponsor the Call

Sign the transaction with the user’s keypair and send it to Grat for sponsorship. Grat will pay both the base fee and the resource fees.
5

Read the Result

After the transaction is included in a ledger, you can parse the result XDR to read the return value of your contract function.

Resource Fees vs Base Fees

In Soroban, every transaction has two fee components:
  • Base Fee: The cost of including the transaction in a ledger (Classic).
  • Resource Fee: The cost of the computation and storage used by the contract.
Grat automatically handles the calculation and payment of both components during the sponsorship process.
Use the estimate() method before sponsoring if you want to show the user exactly how much the application is paying to cover their transaction.
View on GitHub