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

# Prepare a sponsored transaction

> Step 1 of gas sponsorship for trader instances on Polygon. Checks the submitted calls against an ALLOW verification and returns the hashes to sign. One sponsorship per verification. Free.



## OpenAPI

````yaml /openapi.json post /api/v1/gas/prepare
openapi: 3.0.3
info:
  title: Chance API
  version: 1.0.0
  description: >-
    Verify an agent's proposed action against its rules, manage escrow wallets,
    and buy credits. Every verification returns a signed, hash-chained receipt.
servers:
  - url: https://harness.chance.cc
    description: Production
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Verification
    description: Check an action against its rules and fetch past verdicts.
  - name: Credits
    description: Balance and x402 top-ups.
  - name: Escrow wallets
    description: Wallets that only move funds through a verified proposal.
  - name: Trader
    description: Liveness reports from trader containers.
  - name: Gas sponsorship
    description: Sponsored gas for trader instances on Polygon.
  - name: Status
    description: Public deployment facts for checking receipts.
paths:
  /api/v1/gas/prepare:
    post:
      tags:
        - Gas sponsorship
      summary: Prepare a sponsored transaction
      description: >-
        Step 1 of gas sponsorship for trader instances on Polygon. Checks the
        submitted calls against an ALLOW verification and returns the hashes to
        sign. One sponsorship per verification. Free.
      operationId: gasPrepare
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GasPrepareRequest'
      responses:
        '200':
          description: Hashes to sign.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GasPrepareResponse'
        '400':
          description: Invalid body, or the verification is not a sponsorable action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                e0:
                  summary: invalid JSON body
                  value:
                    error: invalid JSON body
                e1:
                  summary: scanId is required
                  value:
                    error: scanId is required
                e2:
                  summary: not_sponsorable_action
                  value:
                    error: not_sponsorable_action
                    message: sponsorship is Polygon-only (eip155:137)
        '401':
          description: No API key, or the key is unknown or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                e0:
                  summary: missing API key (send x-api-key)
                  value:
                    error: missing API key (send x-api-key)
                e1:
                  summary: invalid or revoked API key
                  value:
                    error: invalid or revoked API key
        '403':
          description: Not allowed to sponsor this verification.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                e0:
                  summary: scan_not_found
                  value:
                    error: scan_not_found
                    message: no such scan for this account
                e1:
                  summary: verdict_not_allow
                  value:
                    error: verdict_not_allow
                    message: only an ALLOW verdict can be sponsored
                e2:
                  summary: unknown_instance_wallet
                  value:
                    error: unknown_instance_wallet
                    message: '`from` is not a registered trader instance wallet'
                e3:
                  summary: bind_mismatch
                  value:
                    error: bind_mismatch
                    message: …
                e4:
                  summary: already_sponsored
                  value:
                    error: already_sponsored
                    message: this scan has already been sponsored
        '409':
          description: Gas sponsorship is not configured on this deployment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: gas_not_configured
        '502':
          description: The sponsorship provider failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                e0:
                  summary: alchemy_error
                  value:
                    error: alchemy_error
                    message: …
                e1:
                  summary: prepare_failed
                  value:
                    error: prepare_failed
                    message: …
components:
  schemas:
    GasPrepareRequest:
      type: object
      required:
        - scanId
        - calls
      properties:
        scanId:
          type: string
          description: >-
            An ALLOW verification whose action was an `evm_calls` batch on
            `eip155:137` from a registered trader wallet.
        calls:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EvmCall'
          description: >-
            The calls to send, with a fresh signed quote. They must match the
            judged calls' terms.
    GasPrepareResponse:
      type: object
      properties:
        signatureRequests:
          type: array
          items:
            type: object
            properties:
              i:
                type: integer
                description: Position. Return signatures in this order.
              type:
                type: string
              rawPayload:
                type: string
                description: The 32-byte hash to sign.
              data: {}
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: >-
            An error code (for example `out_of_credits`) or a short sentence
            (for example `intent is required`).
        message:
          type: string
          description: Detail, when present.
    EvmCall:
      type: object
      required:
        - to
      properties:
        to:
          type: string
        data:
          type: string
        value:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: An API key (`chance_sk_live_…`) from https://harness.chance.cc/keys.
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        The same API key sent as `Authorization: Bearer <key>`. If both headers
        are sent, `x-api-key` is used.

````