Todas as lições · CCC (TypeScript SDK) · Começa aqui · Glossário
Transaction size for fee rate is serialized bytes plus 4PráticoDe uma correção
De uma correção · Verificação: em parte certa · Verificada em 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.
Porque importa: 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.
Padrão
}).toBytes().length + 4;Tirado do commit, encurtado.
Reproduzida por um teste
Um teste público corre o que esta lição diz em @ckb-ccc/core 1.23.1, sem nó. Qualquer pessoa o pode correr. Cobre uma parte da lição: the size rule as CCC applies it, not the node count nor weight by cycles.
tests/ccc/transaction-size.test.mjs
- Conceitos
- Transaction building and fees, Data encoding (molecule, hex, bigints)
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-10-17
- Última mudança
- 2026-10-17
- Última verificação
- 2026-11-19
- Verificação contra o commit
- em parte certa: um núcleo verdadeiro, com uma parte solta ou demasiado larga
Fontes (1)
- 2026-10-17 · wildanrhmn/ckb-devnet-explorer · mais deste projeto
Mais sobre 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
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
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.