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

# 任务配置

> Call Builder 与 Writer Plugin 的协议字段。

任务通过已注册的 `type` 和 JSON `config` 选择输入与输出行为。以下示例展示 `config` 内的 JSON，不包含外层 protobuf 消息。区块与记录值仅作示意。

## Call Builder 字段

| 类型 | 字段 |
| - | - |
| `InputsCallConfig` | `function` 或 inline `code.sourceCode`、`callList` |
| `BlockTableCallConfig` | `block`、`triggerSources` 中的 `table`、`functionId` 或 `code`、`params`、可选 `operator` |
| `BlockBundleCallConfig` | `blockBundle.number`、`triggerSources` 中的 `tableId`、`function` 或 `code`、`param`、可选 `operator` |

在位置参数模板中使用 `${<table>}` 替换源数据行。扫描参数为空时，将整行作为唯一参数。bundle 协议键为 `function` 和 `param`，block 协议键为 `functionId` 和 `params`。

### InputsCallConfig

```json theme={null}
{
  "function": "",
  "code": {
    "sourceCode": "def _(chain_id, record):\n    return record\n"
  },
  "callList": [
    [
      "eth",
      {
        "id": "sample"
      }
    ]
  ]
}
```

### BlockTableCallConfig

```json theme={null}
{
  "block": {
    "id": "0xabababababababababababababababababababababababababababababababab",
    "height": 18000000,
    "timestamp": "2024-06-08T00:00:00Z"
  },
  "triggerSources": [
    {
      "table": "chain.trace.eth",
      "functionId": "",
      "code": {
        "sourceCode": "def _(chain_id, record):\n    return record\n"
      },
      "params": [
        "eth",
        "${chain.trace.eth}"
      ]
    }
  ]
}
```

### BlockBundleCallConfig

```json theme={null}
{
  "blockBundle": {
    "number": 18001
  },
  "triggerSources": [
    {
      "tableId": "chain.trace.eth",
      "function": "",
      "code": {
        "sourceCode": "def _(chain_id, record):\n    return record\n"
      },
      "param": [
        "eth",
        "${chain.trace.eth}"
      ]
    }
  ]
}
```

## Writer Plugin 字段

| 类型 | JSON 配置 | 部署 |
| - | - | - |
| `BlockTableWriteHandler` | `targetTable`、包含 `id`、`height`、`timestamp` 的 `block` | block |
| `BlockTableWriteHandler` | `targetTable`、包含 `number` 的 `blockBundle` | bundle |
| `NormalTableWriteHandler` | `targetTable`、可选 `condition`，包含 `column`、`policy` | block 或 bundle |
| `TimeTableWriteHandler` | `targetTable` | block 或 bundle |
| `ReturnValueHandler` | `{}` | block |

`condition.policy` 接受 `UpdateIfSmaller` 或 `UpdateIfLarger`。表 Writer 按目标列投影记录。只有不需要持久化或返回输出时，才省略 handler。

block 表 handler 的上下文必须匹配部署。Debug 写表使用 `debug: true` 请求预览行为，不持久化数据。完成边界见[执行语义](/zh/concepts/execution-semantics)。

## Operator

可选的 `operator` 通过过滤和去重缩小触发行范围。其计划包含以 `read` 为根的 `relations` 链。格式详见 BlockX 仓库的 `docs/specs/substrait_ast.md`，实现归属 [Plugin 系统](/zh/components/plugins)。

## 来源与相关文档

配置结构位于 BlockX 仓库的 `internal/plugin/callbuilder/` 和 `internal/plugin/event/`，名称定义在各自的 `types/types.go` 中。

* [Call Builder 与 Writer Plugin](/zh/concepts/builders-and-handlers)
* [按区块计算](/zh/guides/block-computation)
* [回填历史 bundle](/zh/guides/bundle-backfill)


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