Solana RPC API手册

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

logsSubscribe

Subscribe to transaction logging

请求参数

  • filter: <string>|<object> - filter criteria for the logs to receive results by account type; currently supported:
    • "all" - subscribe to all transactions except for simple vote transactions
    • "allWithVotes" - subscribe to all transactions including simple vote transactions
    • { "mentions": [ <string> ] } - subscribe to all transactions that mention the provided Pubkey (as base-58 encoded string)
  • - (optional) Configuration object containing the following optional fields:
    • (optional) Commitment

    响应结果

    • <integer> - Subscription id (needed to unsubscribe)

    示例代码

    请求:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "logsSubscribe",
      "params": [
        {
          "mentions": [ "11111111111111111111111111111111" ]
        },
        {
          "commitment": "finalized"
        }
      ]
    }
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "logsSubscribe",
      "params": [ "all" ]
    }
    

    响应:

    {"jsonrpc": "2.0","result": 24040,"id": 1}
    

    Notification Format:# Base58 encoding:

    {
      "jsonrpc": "2.0",
      "method": "logsNotification",
      "params": {
        "result": {
          "context": {
            "slot": 5208469
          },
          "value": {
            "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv",
            "err": null,
            "logs": [
              "BPF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success"
            ]
          }
        },
        "subscription": 24040
      }
    }