全部经验 · CCC (TypeScript SDK) · 从这里开始 · 术语表
Transaction size for fee rate is serialized bytes plus 4实践来自一次修复
来自一次修复 · 核对结果:部分正确 · 核对于 2026-11-19
To get a transaction's size as the node counts it, take the molecule serialized size of the full transaction with witnesses (for example ccc.Transaction.from(...).toBytes().length) and add 4 bytes for its offset in the block. A size-based fee rate is fee * 1000 / size in shannons per 1000 bytes; the node's pool actually uses weight, the larger of size and cycles scaled, so it can be higher for cycle-heavy transactions. get_transaction returns snake_case JSON, so map the fields (code_hash to codeHash, dep_type dep_group to depGroup) before passing it to ccc.Transaction.from.
为什么重要: Without the extra 4 bytes, or if witnesses are left out, the computed size and fee rate do not match what the node counts, so the displayed or chosen fee rate is off.
代码模式
}).toBytes().length + 4;摘自提交,已缩短。
已由测试复现
一个公开的测试在 @ckb-ccc/core 1.23.1 上运行这条经验所说的内容,无需节点。任何人都可以运行。 它覆盖了这条经验的一部分: the size rule as CCC applies it, not the node count nor weight by cycles.
tests/ccc/transaction-size.test.mjs
- 概念
- Transaction building and fees, Data encoding (molecule, hex, bigints)
- 证据
- 来自一次修复: 来自一个项目,已对照其提交核对
- 首次出现
- 2026-10-17
- 最近改动
- 2026-10-17
- 最近核对
- 2026-11-19
- 对照提交的核对结果
- 部分正确:核心属实,但有一部分表述松散或范围过宽
来源(1)
- 2026-10-17 · wildanrhmn/ckb-devnet-explorer · 这个项目的更多经验
更多关于CCC (TypeScript SDK)
- Parsing snake_case JSON-RPC transactions in CCC
- Use JsonRpcTransformers.transactionFrom to serialize CCC transactions for CKB/Fiber RPC
- Convert Fiber RPC snake_case scripts to CCC camelCase ScriptLike
引用这条经验
LusoCryptoLabs, "Transaction size for fee rate is serialized bytes plus 4", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/transaction-size-for-fee-rate-is-serialized-bytes-plus-4, CC BY 4.0, last changed 2026-10-17.