> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ana.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Relay a Safe transaction

> Submits an owner-signed Safe `execTransaction` to the chain. Anafi pays the gas. The
Safe checks the owner signatures. Anafi adds no authority and decides only whether
it pays for the transaction.

Anafi pays only for these calls, made directly or as zero-value `CALL` records of a
`delegatecall` into the Safe `MultiSend` of the network:
- `enableModule(adapter)` and `disableModule(prevModule, adapter)` at the Safe
  itself, where `adapter` is the Safe adapter of the network.
- `commitDsl` and `commitDslDirect` at the `AnafiDslRegistry` of the network, with
  the Safe adapter as the `adapter` argument. A `sealedDsl` of `commitDslDirect` can
  be at most one sealed document of the maximum document size.
- On a network with an off-ramp handler: `setFallbackHandler(handler)` at the Safe
  with exactly that handler, and `setOffRampPolicy(terms)` at the Safe.

Every transaction must also have `value`, `gasPrice` and `safeTxGas` equal to 0.
With these values the Safe reverts the whole transaction when the inner call fails.
A signature slot that names the Anafi submitter as a pre-validated signer is refused.

- Who may call: anyone. Only a transaction that the Safe owners signed can execute.
- Before: the Safe exists, its threshold signatures are in the calldata, and the
  transaction uses the current Safe nonce. While fees are on, the Safe must have a
  sponsor (see `GET /api/wallets/{aa}/sponsorship`). Otherwise the owner sends
  `execTransaction` from the owner address.
- Guarantee: a `200` means that the transaction was mined. `success` is the
  receipt status. A `success: false` means that the Safe refused the whole
  transaction and nothing that it asked for happened.
- Only one relay for one Safe runs at a time. A second request answers `429`.

Do not send the same bytes again after a `504`. Read the Safe nonce to learn whether
the transaction ran. See [Safe adapter](/contracts/safe-adapter).




## OpenAPI

````yaml /api/openapi.yaml post /api/wallets/{aa}/safe/sponsor_exec
openapi: 3.1.0
info:
  title: Anafi API
  version: 0.3.0
  summary: The public HTTP API of one Anafi network.
  description: >
    The Anafi API is the HTTP surface of one Anafi network. Each network has its
    own host.

    The public TypeScript SDK `@anafi-cc/anafi-sdk` calls these routes for you,
    and it also

    builds and checks the signed and sealed payloads. You can call the routes
    directly.


    - No API key is necessary today.

    - Request and response bodies are JSON, except where an operation says
    otherwise.

    - A route that carries a confidential payload takes an HPKE-sealed envelope.
    Read
      [Sealed requests](/api-reference/sealed-requests) before you call it without the SDK.
    - Read [Introduction](/api-reference/introduction) for formats and
      [Errors](/api-reference/errors) for the error bodies.

    Browser origin: the API hosts answer CORS only for `https://app.ana.fi`
    today. A browser

    page on another origin cannot call the API directly. A server, a script, or
    your own

    same-origin proxy can call it.
servers:
  - url: https://api.polygon.ana.fi
    description: Polygon PoS (chain id 137)
  - url: https://api.xlayer.ana.fi
    description: X Layer (chain id 196)
  - url: https://api.polygon-amoy.ana.fi
    description: Polygon Amoy testnet (chain id 80002)
security: []
tags:
  - name: Accounts
    description: >-
      Find the accounts of an owner address, and deploy the 1-of-1 Safe of an
      owner.
  - name: Safe relay
    description: Submit an owner-signed Safe transaction. Anafi pays the gas.
  - name: Rules
    description: >-
      Stage a sealed rule document. The engine returns the attestation for the
      on-chain commit.
  - name: Confidential channel
    description: >-
      Read back the rule document and the account state of an account through a
      sealed channel.
  - name: Notification email
    description: Verify the email address that rule notifications go to.
  - name: Activity
    description: Read the payments that the engine made for an account.
  - name: Fees
    description: Read the fee terms of the network and the sponsorship of an account.
  - name: Payments
    description: Ask for the email receipt of a payment made on the pay page.
  - name: Rule language
    description: >-
      Read the rule language reference, and write a rule document from a
      description.
  - name: Bank payouts
    description: >
      Connect a Safe to Monerium for bank payouts in euro, and read the state of
      the

      connection and of the orders. These routes are served only on
      `polygon-amoy`

      (Monerium sandbox). The `polygon` and `xlayer` hosts answer `404`.
  - name: Status
    description: Check that the Anafi API answers.
paths:
  /api/wallets/{aa}/safe/sponsor_exec:
    post:
      tags:
        - Safe relay
      summary: Relay a Safe transaction
      description: >
        Submits an owner-signed Safe `execTransaction` to the chain. Anafi pays
        the gas. The

        Safe checks the owner signatures. Anafi adds no authority and decides
        only whether

        it pays for the transaction.


        Anafi pays only for these calls, made directly or as zero-value `CALL`
        records of a

        `delegatecall` into the Safe `MultiSend` of the network:

        - `enableModule(adapter)` and `disableModule(prevModule, adapter)` at
        the Safe
          itself, where `adapter` is the Safe adapter of the network.
        - `commitDsl` and `commitDslDirect` at the `AnafiDslRegistry` of the
        network, with
          the Safe adapter as the `adapter` argument. A `sealedDsl` of `commitDslDirect` can
          be at most one sealed document of the maximum document size.
        - On a network with an off-ramp handler: `setFallbackHandler(handler)`
        at the Safe
          with exactly that handler, and `setOffRampPolicy(terms)` at the Safe.

        Every transaction must also have `value`, `gasPrice` and `safeTxGas`
        equal to 0.

        With these values the Safe reverts the whole transaction when the inner
        call fails.

        A signature slot that names the Anafi submitter as a pre-validated
        signer is refused.


        - Who may call: anyone. Only a transaction that the Safe owners signed
        can execute.

        - Before: the Safe exists, its threshold signatures are in the calldata,
        and the
          transaction uses the current Safe nonce. While fees are on, the Safe must have a
          sponsor (see `GET /api/wallets/{aa}/sponsorship`). Otherwise the owner sends
          `execTransaction` from the owner address.
        - Guarantee: a `200` means that the transaction was mined. `success` is
        the
          receipt status. A `success: false` means that the Safe refused the whole
          transaction and nothing that it asked for happened.
        - Only one relay for one Safe runs at a time. A second request answers
        `429`.


        Do not send the same bytes again after a `504`. Read the Safe nonce to
        learn whether

        the transaction ran. See [Safe adapter](/contracts/safe-adapter).
      operationId: sponsorSafeExec
      parameters:
        - $ref: '#/components/parameters/AccountPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SponsorSafeExecRequest'
            example:
              network: polygon-amoy
              account: '0xf9836de53d455019ed985896fce8af80be66b7f9'
              execTransactionCalldata: >-
                0x6a761202000000000000000000000000f9836de53d455019ed985896fce8af80be66b7f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000024610b5925000000000000000000000000425fe0a554299d33589edc51387254175478ee0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000413b6a765ede676559e0f261b5b9e339c9f36819c74a67568eb417ff4b379dbfbd4f1d2c8e7a90b3c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d1b00000000000000000000000000000000000000000000000000000000000000
      responses:
        '200':
          description: The transaction was mined.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SponsorSafeExecResponse'
              example:
                txHash: >-
                  0x0c2f8f5b3a6e4d1c9b8a7f6e5d4c3b2a1908f7e6d5c4b3a291807f6e5d4c3b2a
                success: true
        '400':
          description: >
            The request is not one that Anafi can judge:

            - The path `aa` is not an address, or the body is not valid JSON.

            - `network` is not a known network token, or is not the network of
            this host.

            - `account` is not equal to the path `aa`.

            - The calldata is not an `execTransaction` call, has an operation
            other than a
              call or a `delegatecall`, has a malformed `MultiSend` payload, has malformed
              arguments of a known call, or has a `sealedDsl` that is too long.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: the calldata is not a Safe execTransaction call
        '403':
          description: >
            Anafi does not pay for this transaction.

            - JSON `{"code":"account_not_sponsored"}`: fees are on and the Safe
            has no
              sponsor. Send the transaction from the owner address.
            - Plain text: the call is not on the funded list, a value or a gas
            field is not
              zero, the account has no Safe code or is not a Safe that the Safe adapter
              accepts, or a simulation of the transaction reverted. The text says which.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RelaySponsorGateRefusal'
              example:
                code: account_not_sponsored
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
              example: >-
                a leg carries native value; this deployment funds Safe adapter
                lifecycle and DSL commit calls, not transfers out of the Safe
        '413':
          $ref: '#/components/responses/BodyTooLarge'
        '415':
          $ref: '#/components/responses/MissingJsonContentType'
        '422':
          $ref: '#/components/responses/JsonBodyRejected'
        '429':
          description: >-
            Another relay for the same Safe is in progress. Wait for it, then
            read the Safe nonce before you send again.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
        '502':
          description: >
            A chain read or the submission failed, another transaction took the
            nonce, or

            the request reached its time limit before Anafi sent anything. Read
            the Safe

            nonce before you try again.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
        '503':
          description: >-
            The network serves no Safe adapter, or the sponsor record of the
            Safe could not be read.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
        '504':
          description: >
            The transaction was sent but not mined in time. It can still be
            mined, maybe

            under a different hash at the same nonce. The text holds the first
            hash. Do not

            send these bytes again. Read the Safe nonce to learn whether it ran.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/PlainTextError'
components:
  parameters:
    AccountPath:
      name: aa
      in: path
      required: true
      description: >-
        The account address (a Safe or a plain address), as `0x` and 40 hex
        digits in any letter case.
      schema:
        $ref: '#/components/schemas/Address'
      example: '0xf9836de53d455019ed985896fce8af80be66b7f9'
  schemas:
    SponsorSafeExecRequest:
      type: object
      required:
        - network
        - account
        - execTransactionCalldata
      properties:
        network:
          $ref: '#/components/schemas/Network'
          description: The network of the Safe. It must be the network of this host.
        account:
          $ref: '#/components/schemas/Address'
          description: The Safe. It must equal the `aa` path segment.
        execTransactionCalldata:
          $ref: '#/components/schemas/HexBytes'
          description: >-
            The complete ABI-encoded `execTransaction(...)` call of the Safe,
            with the owner signatures.
    SponsorSafeExecResponse:
      type: object
      required:
        - txHash
        - success
      properties:
        txHash:
          $ref: '#/components/schemas/TxHash'
          description: The hash of the mined transaction.
        success:
          type: boolean
          description: >-
            The receipt status. `false` means that the Safe refused the whole
            transaction, for example a bad signature, a used nonce, or an inner
            call that reverted. Nothing that the transaction asked for happened.
    PlainTextError:
      type: string
      description: >-
        A short English sentence. Show it or log it. Do not parse it; branch on
        the status code.
    RelaySponsorGateRefusal:
      type: object
      description: >-
        Anafi does not pay for an owner operation of this account, because fees
        are on and the account has no sponsor.
      required:
        - code
      properties:
        code:
          type: string
          const: account_not_sponsored
    Address:
      type: string
      pattern: ^0x[0-9a-fA-F]{40}$
      description: >-
        A 20-byte address as `0x` and 40 hex digits. Requests accept any letter
        case. Responses use lowercase.
      examples:
        - '0xf9836de53d455019ed985896fce8af80be66b7f9'
    Network:
      type: string
      description: The network token.
      oneOf:
        - const: polygon
          description: Polygon PoS, chain id 137.
        - const: xlayer
          description: X Layer, chain id 196.
        - const: polygon-amoy
          description: Polygon Amoy testnet, chain id 80002.
    HexBytes:
      type: string
      pattern: ^0x([0-9a-fA-F]{2})*$
      description: Bytes as `0x` and an even count of hex digits.
    TxHash:
      type: string
      pattern: ^0x[0-9a-f]{64}$
      description: A transaction hash as `0x` and 64 lowercase hex digits.
  responses:
    BodyTooLarge:
      description: >-
        The body is larger than the limit of the route. The limit is 2 MB for
        `POST /api/dsl/generate` and the bank payout routes, and 512 KiB for all
        other routes.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
    MissingJsonContentType:
      description: 'The request has no `Content-Type: application/json` header.'
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
          example: 'Expected request with `Content-Type: application/json`'
    JsonBodyRejected:
      description: >-
        The body is valid JSON, but a field is missing or has the wrong type or
        format.
      content:
        text/plain:
          schema:
            $ref: '#/components/schemas/PlainTextError'
          example: >-
            Failed to deserialize the JSON body into the target type: missing
            field `eoa` at line 1 column 2

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.