Skip to content

Commit 15391bb

Browse files
committed
fix: Additional feedback
1 parent 87904a4 commit 15391bb

File tree

1 file changed

+44
-28
lines changed

1 file changed

+44
-28
lines changed

content/relayer/guides/stellar-sponsored-transactions-guide.mdx

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Stellar Sponsored Transactions (also known as gasless transactions) allow users
1515

1616
The relayer handles the complexity of fee conversion, token swaps, and XLM fee payment, while users simply pay in their preferred token.
1717

18+
For additional context on fee abstraction in Soroban smart contracts, see [fee abstraction on stellar contracts](/stellar-contracts/fee-abstraction)
19+
1820
## Prerequisites
1921

2022
- A running OpenZeppelin Relayer instance
@@ -352,24 +354,7 @@ Supported operation types:
352354

353355
Soroban Gas Abstraction extends the sponsored transaction concept to Soroban smart contracts. Instead of requiring users to hold XLM for contract invocation fees, users can pay in any Soroban token (e.g., a USDC Soroban token contract). This is powered by a **FeeForwarder smart contract** that wraps the user's contract call with fee collection logic.
354356

355-
**How it differs from Classic Stellar Sponsored Transactions:**
356-
357-
| Aspect | Classic Stellar | Soroban Gas Abstraction |
358-
| -------------------- | ----------------------------------------------- | -------------------------------------------------------- |
359-
| **Transaction type** | Classic operations (payments, trustlines, etc.) | Soroban `InvokeHostFunction` operations |
360-
| **Fee mechanism** | Fee-bump transaction wrapper | FeeForwarder smart contract |
361-
| **Fee token format** | Credit assets (`CODE:ISSUER`) | Soroban token contracts (`C...` address) |
362-
| **Authorization** | Standard transaction signing | User signs a `SorobanAuthorizationEntry` |
363-
| **Submission** | Relayer wraps in fee-bump envelope | Relayer injects signed auth entries and submits directly |
364-
365-
### Prerequisites
366-
367-
- A running OpenZeppelin Relayer instance
368-
- A Stellar relayer configured with `"fee_payment_strategy": "user"`
369-
- A deployed **FeeForwarder contract** on the target network. [Check the OpenZeppelin contract here](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/fee-abstraction)
370-
- The `STELLAR_TESTNET_FEE_FORWARDER_ADDRESS` or `STELLAR_MAINNET_FEE_FORWARDER_ADDRESS` environment variable set to the FeeForwarder contract address
371-
- Allowed tokens configured with Soroban token contract addresses (`C...` format)
372-
- Sufficient XLM balance in the relayer account for network fees
357+
For additional context on the FeeForwarder contract and fee abstraction in Soroban smart contracts, see the [fee abstraction documentation](/stellar-contracts/fee-abstraction).
373358

374359
### Configuration
375360

@@ -411,6 +396,31 @@ Configure the relayer with Soroban token contracts in the `allowed_tokens` list.
411396
}
412397
```
413398

399+
**How it differs from Classic Stellar Sponsored Transactions:**
400+
401+
| Aspect | Classic Stellar | Soroban Gas Abstraction |
402+
| -------------------- | ----------------------------------------------- | -------------------------------------------------------- |
403+
| **Transaction type** | Classic operations (payments, trustlines, etc.) | Soroban `InvokeHostFunction` operations |
404+
| **Fee mechanism** | Fee-bump transaction wrapper | FeeForwarder smart contract |
405+
| **Fee token format** | Credit assets (`CODE:ISSUER`) | Soroban token contracts (`C...` address) |
406+
| **Authorization** | Standard transaction signing | User signs a `SorobanAuthorizationEntry` |
407+
| **Submission** | Relayer wraps in fee-bump envelope | Relayer injects signed auth entries and submits directly |
408+
409+
### Prerequisites
410+
411+
- A running OpenZeppelin Relayer instance
412+
- A Stellar relayer configured with `"fee_payment_strategy": "user"`
413+
- A deployed **FeeForwarder contract** on the target network. [Check the OpenZeppelin contract here](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/fee-abstraction)
414+
- The `STELLAR_TESTNET_FEE_FORWARDER_ADDRESS` or `STELLAR_MAINNET_FEE_FORWARDER_ADDRESS` environment variable set to the FeeForwarder contract address
415+
- **Soroswap contract addresses configured** via environment variables (Router, Factory, and Native Wrapper). These are required for the relayer to get quotes and perform token swaps. See [Soroswap documentation](https://docs.soroswap.finance/) for how to find contract addresses
416+
- Allowed tokens configured with Soroban token contract addresses (`C...` format). **The fee tokens you use must have liquidity pools on [Soroswap](https://app.soroswap.finance/)**, as the relayer uses Soroswap to get quotes and convert tokens to XLM
417+
- **Trustlines** established for fee tokens:
418+
- The **relayer account** must have a trustline to each fee token it accepts
419+
- If testing with a **SAC (Stellar Asset Contract) token**, the **user account** must also have a trustline to the token. See the [Relayer SDK trustline example](https://github.com/OpenZeppelin/openzeppelin-relayer-sdk/tree/main/examples/relayers/stellar/src/sponsored/createTrustline.ts) for how to create trustlines
420+
- Sufficient XLM balance in the relayer account for network fees
421+
422+
### Environment Variables
423+
414424
Set the required environment variables:
415425

416426
<Callout>
@@ -421,18 +431,20 @@ Set the required environment variables:
421431

422432
```bash
423433
# Stellar FeeForwarder Contract Addresses
434+
# Deploy your own or find the address from the OpenZeppelin stellar-contracts repository:
435+
# https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/fee-abstraction
424436
# STELLAR_MAINNET_FEE_FORWARDER_ADDRESS=
425437
STELLAR_TESTNET_FEE_FORWARDER_ADDRESS=
426438

427-
# Stellar Soroswap Router Contract Addresses
439+
# Stellar Soroswap Contract Addresses
440+
# Find these addresses in the Soroswap documentation:
441+
# https://docs.soroswap.finance/
428442
STELLAR_MAINNET_SOROSWAP_ROUTER_ADDRESS=
429443
STELLAR_TESTNET_SOROSWAP_ROUTER_ADDRESS=
430444

431-
# Stellar Soroswap Factory Contract Addresses
432445
STELLAR_MAINNET_SOROSWAP_FACTORY_ADDRESS=
433446
STELLAR_TESTNET_SOROSWAP_FACTORY_ADDRESS=
434447

435-
# Stellar Soroswap Native Wrapper (XLM) Contract Addresses
436448
STELLAR_MAINNET_SOROSWAP_NATIVE_WRAPPER_ADDRESS=
437449
STELLAR_TESTNET_SOROSWAP_NATIVE_WRAPPER_ADDRESS=
438450
```
@@ -441,9 +453,9 @@ STELLAR_TESTNET_SOROSWAP_NATIVE_WRAPPER_ADDRESS=
441453

442454
The Soroban gas abstraction flow uses the same endpoints as classic sponsored transactions but with key differences in the request/response payloads and an additional authorization signing step.
443455

444-
#### Step 1: Get Fee Quote
456+
#### Step 1: Get Fee Quote (Optional)
445457

446-
Estimate the fee for a Soroban contract invocation in your preferred token.
458+
This step is **optional and informational**. It allows you to estimate the fee cost before building the transaction, which is useful for displaying the expected cost to users. You can skip directly to Step 2 (Build) if you don't need a fee estimate upfront.
447459

448460
**Endpoint:** `POST /api/v1/relayers/{relayer_id}/transactions/sponsored/quote`
449461

@@ -490,6 +502,10 @@ Prepare a Soroban transaction that wraps your contract call with the FeeForwarde
490502
}
491503
```
492504

505+
<Callout type="warn">
506+
The authorization entry has a **2-minute expiration window** (~24 ledgers at ~5 seconds each). This means you must sign and submit the transaction promptly after building it. If you are testing manually or your flow involves back-and-forth steps, be aware that the authorization may expire before submission. If your transaction fails with an expiration error, rebuild and re-sign the transaction.
507+
</Callout>
508+
493509
**Response:**
494510

495511
The response includes a `user_auth_entry` field containing the Soroban authorization entry that the user must sign. This authorization entry authorizes the FeeForwarder contract to collect fees in the specified token on the user's behalf.
@@ -621,11 +637,11 @@ The contract's `forward()` function takes these parameters:
621637
### Best Practices for Soroban Gas Abstraction
622638

623639
1. **Use the Quote endpoint first**: Always get a fee estimate before building to show users the expected cost, including the max fee with slippage
624-
2. **Handle authorization expiration**: Authorization entries expire at a specific ledger. Rebuild if the authorization has expired
625-
3. **Validate token contract addresses**: Ensure fee tokens use valid Soroban contract addresses (`C...` format, 56 characters)
626-
4. **Monitor resource fees**: Soroban transactions have dynamic resource fees based on CPU instructions, storage reads/writes, and ledger entry access. The relayer applies a 15% buffer, but complex contract calls may need higher limits
627-
5. **Set appropriate max fees**: Configure `max_allowed_fee` per token to prevent excessive fees during network congestion
628-
6. **Configure the FeeForwarder address**: Ensure the correct FeeForwarder contract address is set via environment variables for each network
640+
2. **Handle authorization expiration**: Authorization entries have a **2-minute expiration window**. Sign and submit promptly after building. If the authorization expires, rebuild and re-sign the transaction
641+
4. **Validate token contract addresses**: Ensure fee tokens use valid Soroban contract addresses (`C...` format, 56 characters)
642+
5. **Monitor resource fees**: Soroban transactions have dynamic resource fees based on CPU instructions, storage reads/writes, and ledger entry access. The relayer applies a 15% buffer, but complex contract calls may need higher limits
643+
6. **Set appropriate max fees**: Configure `max_allowed_fee` per token to prevent excessive fees during network congestion
644+
7. **Configure the FeeForwarder address**: Ensure the correct FeeForwarder contract address is set via environment variables for each network
629645

630646
## Additional Resources
631647

0 commit comments

Comments
 (0)