CKB Pulse
Lições

O que a CKB aprendeu

Começa aqui · Glossário · Testa-te · Feed

As lições estão escritas em inglês, por isso pesquise em inglês.

Prático

174 lições encontradas. Todas as lições

Página 13 de 15

Deriving minimum cell capacity with ccc.CellOutput.from and output dataPráticoReproduzida

In CCC, calling ccc.CellOutput.from({lock, type}, outputData) without a capacity fills capacity with the cell's occupied size, so it serves as the minimum capacity check for change or receipt cells. This commit uses it to reject dust change before and after subtracting the fee (via transaction.estimateFee), and to top up a receipt cell whose received CKB is below its occupied capacity.

#Capacity and cell size #Transaction building and fees · Fontes (1) · 2026-10-01

Light client set_scripts "all" replaces the whole registered script setPráticoDe uma correção

The CKB light client's set_scripts with the all command replaces every registered script, so a call carrying only one wallet's lock script unregisters all other wallets. When several scripts must stay tracked, either pass the full set with each script's own start block, or use the partial command to update only the changed script. If registrations can race, serialise them so a stale full set cannot overwrite a newer one.

#Indexer queries and cell collection #Network and RPC reliability · Fontes (1) · 2026-09-30

Porting the sighash_all signing message into a Rust lock scriptPráticoDe uma correção

To reproduce secp256k1_blake160_sighash_all's message in a ckb-std lock, hash with ckb blake2b: tx hash, then the first GroupInput witness parsed as WitnessArgs with its lock field zero filled (same length) and u64 LE length prefixed, then the other GroupInput witnesses, then every Source::Input witness at index >= the total input count (each length prefixed). The commit counts inputs by probing load_input_since until IndexOutOfBound.

#Witnesses and signatures · Fontes (1) · 2026-09-29

Derive devnet Spore and system script cell deps from a fresh OffCKB exportPráticoVista outra vez

Do not hardcode devnet code hashes and cell dep out points (secp256k1, Spore, cluster) in an example: they come from the local OffCKB devnet and can drift when OffCKB's bundled scripts change. Export them with `offckb system-scripts --network devnet --export-style ccc` before start, fail if a needed script lacks codeHash, hashType or a cellDep outPoint, and build both the CCC client config and the Spore SDK lumos config from that one file.

#Cell deps and script lookup #Testing and devnet · Fontes (2) · 2026-09-29

Use JsonRpcTransformers.transactionFrom to serialize CCC transactions for CKB/Fiber RPCPráticoReproduzida

Serializing a ccc.Transaction with ccc.stringify keeps cached input fields (cellOutput, outputData) that a native RPC such as Fiber submitSignedFundingTx does not expect. JsonRpcTransformers.transactionFrom from @ckb-ccc/core/advanced emits snake_case hex with inputs containing only previous_output and since, while keeping the tx hash and witnesses unchanged, as the commit's tests check.

#Data encoding (molecule, hex, bigints) #Transaction building and fees · Fontes (1) · 2026-09-28

ckb-cli needs --skip-check to sign and send transactions with custom locksPráticoDe uma correção

ckb-cli refuses transactions whose inputs or outputs use a lock it cannot classify (for example a custom type script based lock with 1 byte of args). `tx sign-inputs` then signs nothing, reporting `invalid lock script ... args.length` and leaving the signatures map and witness empty, and `tx send` refuses the file. Pass `--skip-check` to both sign-inputs and send; otherwise send fails with -2 ERROR_ENCODING because the secp lock reads an empty witness. Since this disables ckb-cli's own checks, run your own verifier on the signed file between sign-inputs and send.

Joined with toastmanAu/daowow@6f4cb48641.

#Witnesses and signatures #Transaction building and fees · Fontes (2) · 2026-09-26

Use findCellsOnChain, not findCells, for block range queries in CCCPráticoVerificada pelo dono

In CCC, client.findCells merges the client's local cache of cells it has sent, and its search key takes no blockRange filter. To list live cells created in a block range, call client.findCellsOnChain with filter.blockRange set to [from, to), where the end is exclusive. This queries the indexer directly.

#Indexer queries and cell collection · Fontes (1) · 2026-09-25

Absolute epoch since needs the 0x20 metric flagPráticoDe uma correção

An input's since meant as an absolute epoch must have bit 61 set (0x2000000000000000) with bit 63 (relative) and bit 62 clear (RFC 0017). With all three top bits zero the node reads the same number as an absolute block number. The epoch number is in the low 24 bits (raw & 0xffffff), with index and length above it, so check the epoch number inclusively against the required epoch before signing.

since flag bits, not covered

#Since and time locks · Fontes (1) · 2026-09-25

Recompute occupied capacity when a state cell grows in a transitionPráticoDe uma correção

When a transaction replaces a cell with one holding larger data (here 101 to 207 bytes under the same type script), compute the new occupied floor as 8 + data length + lock (32 code hash + 1 hash type + args) + type (32 + 1 + args) bytes in CKB, and top up from another input if the old capacity falls short (312 CKB input vs a 318 CKB floor here). If the type script also requires output capacity >= input capacity, use the larger of the two bounds rather than shrinking to the floor.

adds top up and max(floor, input capacity) rule beyond the occupied capacity formula lesson

#Capacity and cell size #Transaction building and fees · Fontes (1) · 2026-09-25

Absolute epoch since needs the 0x20 metric flag in the top bytePráticoDe uma correção

An input since meaning "not before epoch N" must be 0x2000000000000000 | N: top byte 0x20 (absolute, epoch metric) with the epoch number in the low 24 bits. Without the flag the node reads the value as an absolute block number, which for any realistic epoch is already past, so the node enforces no epoch bound. A script that reads since as an epoch must check the metric flag itself, as this project's contract does by refusing a since whose top byte is not 0x20.

Builder side rule for setting the epoch flag.

#Since and time locks · Fontes (2) · 2026-09-25

Place a script's raw witness at the index of the input it validatesPráticoDe uma correção

When a type script reads its proof with load_witness(index, Source::Input) for its own input, the builder must put that raw witness at exactly that input's index. This commit puts the ledger cell at input 0 so its proof is witness 0, and pads the remaining witnesses with "0x" so witnesses.length equals inputs.length and a later funding/signing step appends rather than displaces it.

#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-09-25

Treat an absent WitnessArgs.lock as a load failure in ckb-std lock scriptsPráticoDe uma correção

With ckb-std, `load_witness_args(0, Source::GroupInput)` can succeed while `WitnessArgs.lock` is an empty BytesOpt, so call `lock().to_opt()` and return an error on None before reading `raw_data()`. The commit's ckb-testtool tests check both a missing witness and a WitnessArgs with no lock field, and both fail with the load witness error.

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-09-25

Página 13 de 15

Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.