Prepares a sponsored (gasless) transaction with fee payments.

This endpoint builds a transaction where the relayer will pay the network fees on behalf of the user. The user pays fees in a token of their choice (e.g., USDC) instead of the native network currency.

The endpoint accepts either a pre-built transaction XDR or a set of operations to build a transaction from. It returns a prepared transaction that includes:

  • The transaction XDR (base64 encoded) ready for signing
  • The fee amount in both the fee token and native currency (stroops for Stellar)
  • The fee token identifier
  • The transaction validity timestamp

After receiving the prepared transaction, the user must sign it and submit it through the standard transaction submission endpoint. For Stellar, the transaction will be wrapped in a fee-bump transaction where the relayer pays the network fees.

POST
/api/v1/relayers/{relayer_id}/transactions/sponsored/build
AuthorizationBearer <token>

In: header

Path Parameters

relayer_idstring

The unique identifier of the relayer

Solana-specific prepare transaction request parameters

fee_tokenstring
transactionEncodedSerializedTransaction

Stellar-specific prepare transaction request parameters (classic and Soroban)

fee_tokenstring

Asset identifier for fee token. For classic: "native" or "USDC:GA5Z..." format. For Soroban: contract address (C...) format.

operations?array<OperationSpec> | null

Operations array to build transaction from Mutually exclusive with transaction_xdr field

source_account?string | null

Source account address (required when operations are provided) For gasless transactions, this should be the user's account address

transaction_xdr?string | null

Pre-built transaction XDR (base64 encoded, signed or unsigned) Mutually exclusive with operations field. For Soroban gas abstraction: pass XDR containing InvokeHostFunction operation.

Response Body

curl -X POST "https://loading/api/v1/relayers/string/transactions/sponsored/build" \  -H "Content-Type: application/json" \  -d '{    "fee_token": "string",    "transaction": "string"  }'
{
  "data": {
    "fee_in_stroops": "100000",
    "fee_in_token": "1.5",
    "fee_token": "USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
    "transaction": "AAAAAgAAAAD...",
    "valid_until": "2024-01-01T00:00:00Z"
  },
  "message": "Sponsored transaction built successfully",
  "success": true
}
{
  "data": null,
  "message": "Bad Request",
  "success": false
}
{
  "data": null,
  "message": "Unauthorized",
  "success": false
}
{
  "data": null,
  "message": "Relayer with ID relayer_id not found",
  "success": false
}
{
  "data": null,
  "message": "Too Many Requests",
  "success": false
}
{
  "data": null,
  "message": "Internal Server Error",
  "success": false
}