CKB Contract Flow

.bit Time Index State Type 约束.bit Time Index State Type Constraints

来源:dotbitHQ/ckb-time-script @37343ab contracts/index-state-typeSource: dotbitHQ/ckb-time-script @37343ab contracts/index-state-type
Type 脚本Type script身份 / 钱包Identity / wallet主网Mainnet测试网Testnet开源Open source社区Community
贡献者:Contributed by @duanyytop @duanyytop, @linkdesu @linkdesu

给 AI agent:For AI agents: dotbit_time_index_state.md · llms.txt

0 → 1创建Create

Inputs 输入Inputs
(无)(none)
Outputs 输出Outputs
Index State CellCell{ type: { codeHash: INDEX_STATE, args: any }, data: index u8 ‖ sum u8 = 12 }

限制Constraints

  • data2 字节2 bytes7
  • index< 129
  • sum= 128

1 → 1更新:index 前进一格Update: index advances one

Inputs 输入Inputs
Index State Celldata: i ‖ 12
Outputs 输出Outputs
Index State Celldata: i+1 (or 0 when i ≥ 11) ‖ 12
data 字节布局data byte layout
index1B
sum1B
  • index1B最新 Info cell 的序号index of the newest Info cell< 129 · 10
  • sum1BInfo cell 总数number of Info cells= 128

限制Constraints

  • output组里第一个输入和输出都存在the group has a first input and output6
  • output data同创建as in create7 · 8 · 9
  • index输入 index ≥ 11 → 0,否则 +1(不检查输入 data 的其他部分)input index ≥ 11 → 0, else +1 (the rest of input data is not checked)10

1 → 0回收Recycle

Inputs 输入Inputs
Index State CellCell{ type: INDEX_STATE }
Outputs 输出Outputs
(无)(none)

限制Constraints

  • —输出里没有同 code hash 的 type 即通过passes when no output has a type with this code hash—
部署与来源Deployments & source 未核验unverified
源码source
dotbitHQ/ckb-time-script@37343ab5 · contracts/index-state-type/src/entry.rs · contracts/index-state-type/src/error.rs · libs/common/src/constants.rs · migrations/mainnet/2021-08-24-000000.json (commit 37343ab "chore: deploy script to mainnet" adds migrations/mainnet/2021-08-24-000000.json (hashes used here); contract code last changed at a2fa7d9 (2021-08-09). No reproducible build attempted.)
二进制核验binary check
未核验unverified no binary or checksum at the recorded commit matched the deployed data hash (reproducible build not attempted)
网络networkcode_hashcell_deptype_id args数据哈希data hash部署交易deploy tx
mainnet0x3a468d53352eb855521dabed0dc7036929bfe72766ad58f801edfbae564f7b43 type0xae3197c306…24dc61b3:0 code0x0544efd115…cbbf8f9f0xb575f6dd64…b507bbae0xae3197c306…24dc61b3 #15198603
testnet0x554cff969f3148e3c620749384004e9692e67c429f621554d139b505a281c7b8 type0x654f8a271d…d7f3ea64:0 code0x8c73c41da8…8df4ac2b0xb575f6dd64…b507bbae0x654f8a271d…d7f3ea64 #2386188
链上数据核对于 on-chain data checked 2026-11-06
这两个脚本组成 .bit 的链上时间 / 区块高度预言机:1 个 Index State cell 指向 12 个 Info cell 中最新的一个,每次更新同时改 Index State 和一个 Info cell。The two scripts form the .bit on-chain time / block-number oracle: one Index State cell points to the newest of 12 Info cells; each update rewrites the Index State and one Info cell.
“输入里是否已有本脚本”只比较 code_hash,不比较 args:输入有、输出没有就当作回收直接通过,任何持有 lock 的人都能销毁。"Is this script already in the inputs" compares code_hash only, not args: present in inputs but absent from outputs is treated as recycling and always passes; whoever holds the lock can destroy the cell.
合约没有检查谁能更新:权限完全来自 cell 的 lock。The scripts do not check who may update; authority comes entirely from the lock of the cells.
部署:哈希来自仓库 migrations(主网 2021-08-24、测试网 2021-08-09-103746),链上 code cell 已核对;二进制没有可复现构建。Deployment: hashes from the repo migrations (mainnet 2021-08-24, testnet 2021-08-09-103746), checked on chain; no reproducible build of the binary.
错误码:1–4 syscall · 6 IndexStateTypeNotExist · 7 IndexStateDataLenError · 8 InfoAmountError · 9 IndexStateOutOfBound · 10 IndexIncreaseErrorError codes: 1–4 syscall · 6 IndexStateTypeNotExist · 7 IndexStateDataLenError · 8 InfoAmountError · 9 IndexStateOutOfBound · 10 IndexIncreaseError