anyone_can_pay(lock)约束anyone_can_pay (lock) Constraints

来源:ckb-production-scripts / c/anyone_can_pay.c@e570c11 · mainnet 0xd369…2354 / testnet 0x3419…1356,hash_type type(RFC 0026)Source: ckb-production-scripts / c/anyone_can_pay.c@e570c11 · mainnet 0xd369…2354 / testnet 0x3419…1356, hash_type type (RFC 0026)
Lock 脚本Lock script代币 / UDTToken / UDT身份 / 钱包Identity / wallet主网Mainnet测试网Testnet开源Open sourceNervos 官方Nervos

A所有者签名花费Owner spends with signature

Inputs 输入Inputs
inputCell{ lock: { codeHash: ACP, args: pubkey_hash 20B ‖ ckb_min? ‖ udt_min? } }
witnessWitnessArgs{ lock: signature 65B }
➜
Outputs 输出Outputs
outputs:任意outputs: anyCell{ lock: 任意 }Cell{ lock: any }
args 字节布局args byte layout
pubkey_hash20B
ckb_min?1B
udt_min?1B
  • pubkey_hash 20B blake160(pubkey) 签名者signer (-31)
  • ckb_min? 1B 最小转入 CKB = 10^x shannonmin CKB payment = 10^x shannon 可选optional (-1)
  • udt_min? 1B 最小转入 UDT = 10^xmin UDT payment = 10^x 可选optional (-1)

限制Constraints

  • args:: 20–22 字节20–22 bytes (-1)
  • signature:: 与 secp256k1_blake160_sighash_all 相同规则same rules as secp256k1_blake160_sighash_all (-11 / -14 / -31)

B无签名付款解锁(任何人可存入)Payment unlock without signature (anyone can deposit)

Inputs 输入Inputs
ACP 输入(同 lock)ACP inputs (same lock)Cell{ lock: ACP(args), capacity: C, type: T?, data: udt u128 (T) / empty }
witnesslock 非 65 字节签名(或为空)lock is not a 65-byte signature (or empty)
➜
Outputs 输出Outputs
同 lock 输出(与输入一一配对,按 type 匹配)same-lock output (paired 1:1 with input by type)Cell{ lock: ACP(args), type: same T, capacity: ≥ C + 10^ckb_min or = C, udt: ≥ U + 10^udt_min or = U }

限制Constraints

  • type hash:: 同 lock 输入 ≤ 256 个≤ 256 group inputs (-43)
  • data:: 无 type 的 cell data 必须为空;有 type 的 data ≥ 16 字节no-type cells have empty data; typed cells data ≥ 16B (-2)
  • amount:: CKB 或 UDT 至少一个增加 ≥ 最小值,另一个保持不变(不得减少)CKB or UDT increases by ≥ minimum, the other stays unchanged (-42)
  • pairing:: 每个同 lock 输出恰对应一个同 type 的输入each same-lock output pairs with exactly one input of the same type (-44 / -45)
  • pairing:: 每个输入恰对应一个输出each input pairs with exactly one output (-44 / -46)
部署与来源Deployments & source 未核验unverified
源码source nervosnetwork/ckb-production-scripts@e570c11a · c/anyone_can_pay.c (pinned in the plugin header)
二进制核验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
mainnet0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354 type0x4153a20149…11c25c4d:0 dep_group0xde8b879bd1…a863610c0xcd69ba816f…86cb31e60x58eb58e2e3…ed6d6876 #3279959
testnet0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356 type0xec26b0f85e…60fb96a6:0 dep_group0xb9c8cb04f4…d5ffde460xcd69ba816f…86cb31e60xce29e27734…4d8ba374 #678445
链上数据核对于 on-chain data checked 2026-10-20
错误码:-1 ARGUMENTS_LEN · -2 ENCODING · -3 SYSCALL · -21 SCRIPT_TOO_LONG · -41 OVERFLOW · -42 OUTPUT_AMOUNT_NOT_ENOUGH · -43 TOO_MUCH_TYPE_HASH_INPUTS · -44 NO_PAIR · -45 DUPLICATED_INPUTS · -46 DUPLICATED_OUTPUTSError codes: -1 ARGUMENTS_LEN · -2 ENCODING · -3 SYSCALL · -21 SCRIPT_TOO_LONG · -41 OVERFLOW · -42 OUTPUT_AMOUNT_NOT_ENOUGH · -43 TOO_MUCH_TYPE_HASH_INPUTS · -44 NO_PAIR · -45 DUPLICATED_INPUTS · -46 DUPLICATED_OUTPUTS
10^x 溢出时最小值视为 u64/u128 最大值(即该资产不能用于满足条件)If 10^x overflows the minimum becomes MAX (that asset can't satisfy the condition)
GitHub · gpBlockchain/ckb-contract-flow-html