---
title: "Prepares a sponsored (gasless) transaction with fee payments."
method: POST
path: "/api/v1/relayers/{relayer_id}/transactions/sponsored/build"
tags: ["Relayers"]
---

# Prepares a sponsored (gasless) transaction with fee payments.

`POST /api/v1/relayers/{relayer_id}/transactions/sponsored/build`

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.

## Path parameters

- `relayer_id` string, required

## Request body

- union — Network-agnostic prepare transaction request parameters for gasless transactions. Contains network-specific request parameters for preparing transactions with fee payments. The network type is inferred from the relayer's network configuration. For Stellar, supports both classic and Soroban gas abstraction: - Classic: Pass operations or transaction_xdr with classic fee token - Soroban: Pass transaction_xdr containing InvokeHostFunction, user_address, and contract fee token
  - SolanaPrepareTransactionRequestParams
    - `fee_token` string, required
    - `transaction` string, required
  - StellarPrepareTransactionRequestParams
    - `fee_token` string, required — Asset identifier for fee token. For classic: "native" or "USDC:GA5Z..." format. For Soroban: contract address (C...) format.
    - `operations` OperationSpec[], nullable — Operations array to build transaction from Mutually exclusive with transaction_xdr field
      - union
        - object
          - `amount` string, required — Amount in stroops, encoded as a decimal string to preserve precision.
          - `asset` union, required
            - object
              - …
            - object
              - …
            - object
              - …
          - `destination` string, required
          - `type` 'payment', required
        - object
          - `args` unknown[], required
            - unknown
          - `auth` union — Authorization specification for Soroban operations
            - object — No authorization required
              - …
            - object — Use the transaction source account for authorization
              - …
            - object — Use specific addresses for authorization
              - …
            - object — Advanced format - provide complete XDR auth entries as base64-encoded strings
              - …
          - `contract_address` string, required
          - `function_name` string, required
          - `type` 'invoke_contract', required
        - object
          - `auth` union — Authorization specification for Soroban operations
            - object — No authorization required
              - …
            - object — Use the transaction source account for authorization
              - …
            - object — Use specific addresses for authorization
              - …
            - object — Advanced format - provide complete XDR auth entries as base64-encoded strings
              - …
          - `constructor_args` unknown[], nullable
            - unknown
          - `salt` string, nullable
          - `source` union, required — Represents the source for contract creation
            - object
              - …
            - object
              - …
          - `type` 'create_contract', required
          - `wasm_hash` string, required
        - object
          - `auth` union — Authorization specification for Soroban operations
            - object — No authorization required
              - …
            - object — Use the transaction source account for authorization
              - …
            - object — Use specific addresses for authorization
              - …
            - object — Advanced format - provide complete XDR auth entries as base64-encoded strings
              - …
          - `type` 'upload_wasm', required
          - `wasm` union, required — Represents different ways to provide WASM code
            - object
              - …
            - object
              - …
    - `source_account` string, nullable — Source account address (required when operations are provided) For gasless transactions, this should be the user's account address
    - `transaction_xdr` string, nullable — Pre-built transaction XDR (base64 encoded, signed or unsigned) Mutually exclusive with operations field. For Soroban gas abstraction: pass XDR containing InvokeHostFunction operation.

## Response `200`

Sponsored transaction built successfully

- ApiResponseSponsoredTransactionBuildResponse
  - `data` union — Network-agnostic prepare transaction response for gasless transactions. Contains network-specific prepare transaction results.
    - SolanaPrepareTransactionResult
      - `fee_in_lamports` string, required
      - `fee_in_spl` string, required
      - `fee_token` string, required
      - `transaction` string, required
      - `valid_until_blockheight` integer, required
    - StellarPrepareTransactionResult
      - `fee_in_stroops` string, required — Fee amount in stroops (as string)
      - `fee_in_token` string, required — Fee amount in token (raw units as string)
      - `fee_in_token_ui` string, required — Fee amount in token (decimal UI representation as string)
      - `fee_token` string, required — Asset identifier for fee token
      - `max_fee_in_token` string, nullable — Maximum fee in token amount (raw units as string). Only present for Soroban gas abstraction - includes slippage buffer.
      - `max_fee_in_token_ui` string, nullable — Maximum fee in token amount (decimal UI representation as string). Only present for Soroban gas abstraction - includes slippage buffer.
      - `transaction` string, required — Extended transaction XDR (base64 encoded)
      - `user_auth_entry` string, nullable — User authorization entry XDR (base64 encoded). Present for Soroban gas abstraction - user must sign this auth entry.
      - `valid_until` string, required — Transaction validity timestamp (ISO 8601 format)
  - `error` string
  - `metadata` PluginMetadata
    - `logs` LogEntry[], nullable
      - `level` 'log' | 'info' | 'error' | 'warn' | 'debug' | 'result', required
      - `message` string, required
    - `traces` unknown[], nullable
      - unknown
  - `pagination` PaginationMeta
    - `current_page` integer, required
    - `per_page` integer, required
    - `total_items` integer, required
  - `success` boolean, required

## Other responses

- `400` — Bad Request - Invalid request parameters
- `401` — Unauthorized
- `404` — Not Found
- `429` — Too Many Requests
- `500` — Internal server error

## Changes

- **2026-06-05** `97fada1b2001` — 2 breaking
  - added the pattern `^-?[0-9]+$` to the request property `oneOf[#/components/schemas/StellarPrepareTransactionRequestParams]/operations/items/oneOf[subschema #1]/amount`
  - the `oneOf[#/components/schemas/StellarPrepareTransactionRequestParams]/operations/items/oneOf[subschema #1]/amount` request property type changed from `integer` to `string`, and format from `int64` to no format
- **2026-02-09** `6408963b7c93` — 3 info
  - added the optional property `data/oneOf[#/components/schemas/StellarPrepareTransactionResult]/max_fee_in_token` to the response with the `200` status
  - added the optional property `data/oneOf[#/components/schemas/StellarPrepareTransactionResult]/max_fee_in_token_ui` to the response with the `200` status
  - added the optional property `data/oneOf[#/components/schemas/StellarPrepareTransactionResult]/user_auth_entry` to the response with the `200` status
- **2025-12-02** `b62ae34bc27a` — 1 info
  - endpoint added
- **2025-10-31** `5487da58bf15` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/openzeppelin/apis/openzeppelin-relayer-api/changes/api/v1/relayers/:relayer_id/transactions/sponsored/build/post.md)

---

[API](https://skmtc.dev/openzeppelin/apis/openzeppelin-relayer-api.md) · [All operations](https://skmtc.dev/openzeppelin/apis/openzeppelin-relayer-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/openzeppelin/openzeppelin-relayer-api/revisions/e6e7514284f5/schema)
