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

# sendTransaction

> 将签名的交易提交到集群进行处理。

此方法不会以任何方式更改交易；它将客户端创建的交易原样传递给节点。

如果节点的 rpc 服务接收到交易，此方法会立即成功，而无需等待任何确认。此方法的成功响应并不保证交易被集群处理或确认。

虽然 rpc 服务会合理地重试提交，但如果交易的 recent\_blockhash 在交易落地之前过期，交易可能会被拒绝。

使用 [getSignatureStatuses](/zh/api-reference/rpc/http/getsignaturestatuses) 确保交易被处理和确认。

在提交之前，会执行以下预检：

1. 验证交易签名
2. 根据预检承诺指定的银行槽位模拟交易。如果失败，将返回错误。如果需要，可以禁用预检。建议指定相同的承诺和预检承诺以避免混淆行为。

返回的签名是交易中的第一个签名，用于标识交易（交易 ID）。此标识符可以在提交前轻松从交易数据中提取。

## 请求参数

<ParamField body="transaction" type="string" required>
  完全签名的Solana交易，编码为base-58字符串以供区块链提交。
</ParamField>

<ParamField body="encoding" type="string">
  用于Solana交易负载的数据编码格式。

  * `base58`
  * `base64`
</ParamField>

<ParamField body="skipPreflight" type="boolean">
  如果为true，则绕过Solana的预检交易验证以加快提交速度。
</ParamField>

<ParamField body="preflightCommitment" type="string">
  Solana网络承诺级别，用于交易验证检查。

  * `confirmed`
  * `finalized`
  * `processed`
</ParamField>

<ParamField body="maxRetries" type="number">
  Solana交易提交失败的最大自动重试次数。
</ParamField>

<ParamField body="minContextSlot" type="number">
  交易处理所需的最低Solana区块链插槽。
</ParamField>


## OpenAPI

````yaml zh/openapi/rpc-http/sendTransaction.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: 快速可靠的Solana交易提交API，用于将签名交易发送到Solana区块链，具有可配置的预检检查和重试选项。
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://mainnet.helius-rpc.com
    description: 主网RPC端点
  - url: https://devnet.helius-rpc.com
    description: 开发网RPC端点
security: []
paths:
  /:
    post:
      tags:
        - RPC
      summary: sendTransaction
      description: >-
        提交已签名的交易到Solana区块链网络，并提供可配置选项。这个重要的API使应用程序能够广播交易以进行验证并包含在账本中，支持所有Solana交易类型，包括代币转移、NFT铸造、智能合约调用和程序部署。功能包括预检检查、可定制的重试逻辑以及用于跟踪确认状态的即时交易签名响应。
      operationId: sendTransaction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  enum:
                    - '2.0'
                  description: JSON-RPC协议版本。
                  example: '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: 请求的唯一标识符。
                  example: '1'
                  default: '1'
                method:
                  type: string
                  enum:
                    - sendTransaction
                  description: 要调用的RPC方法名称。
                  example: sendTransaction
                  default: sendTransaction
                params:
                  type: array
                  description: 发送交易的参数。
                  default:
                    - >-
                      4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT
                  items:
                    oneOf:
                      - type: string
                        description: 完全签名的 Solana 交易，编码为 base-58 字符串，用于区块链提交。
                        example: >-
                          4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT
                      - type: object
                        description: Solana 交易提交和处理的高级配置选项。
                        properties:
                          encoding:
                            type: string
                            description: 用于 Solana 交易负载的数据编码格式。
                            enum:
                              - base58
                              - base64
                            example: base64
                          skipPreflight:
                            type: boolean
                            description: 当为 true 时，绕过 Solana 的预检交易验证以加快提交速度。
                            example: false
                          preflightCommitment:
                            type: string
                            description: Solana 网络用于交易验证检查的承诺级别。
                            enum:
                              - confirmed
                              - finalized
                              - processed
                            example: finalized
                          maxRetries:
                            type: integer
                            description: Solana 交易提交失败时的最大自动重试次数。
                            example: 5
                          minContextSlot:
                            type: integer
                            description: 交易处理所需的最小 Solana 区块槽。
                            example: 1000
            example:
              jsonrpc: '2.0'
              id: '1'
              method: sendTransaction
              params:
                - >-
                  4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT
      responses:
        '200':
          description: 成功发送交易。
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    enum:
                      - '2.0'
                    description: JSON-RPC 协议版本。
                    example: '2.0'
                  id:
                    type: string
                    description: 与请求匹配的标识符。
                    example: '1'
                  result:
                    type: string
                    description: 用于跟踪确认状态和交易历史的唯一 Solana 交易签名。
                    example: >-
                      2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb
              example:
                jsonrpc: '2.0'
                id: '1'
                result: >-
                  2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb
        '400':
          description: 错误请求 - 请求参数无效或请求格式错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: Invalid params
                id: '1'
        '401':
          description: 未授权 - API 密钥无效或缺失。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: Unauthorized
                id: '1'
        '429':
          description: 请求过多 - 超出速率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: Too many requests
                id: '1'
        '500':
          description: 内部服务器错误 - 服务器发生错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: 内部错误
                id: '1'
        '503':
          description: 服务不可用 - 服务暂时不可用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: 服务不可用
                id: '1'
        '504':
          description: 网关超时 - 请求超时。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: 网关超时
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: JSON-RPC协议版本。
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: 错误代码。
              example: -32602
            message:
              type: string
              description: 错误信息。
            data:
              type: object
              description: 关于错误的附加数据。
        id:
          type: string
          description: 与请求匹配的标识符。
          example: '1'
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: 您的Helius API密钥。您可以在[仪表板](https://dashboard.helius.dev/api-keys)中免费获取一个。

````