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.

toastmanAu/daowow

Lições de toastmanAu/daowow

github.com/toastmanAu/daowow

Manténs este projeto? Confirma as lições 1 a 30 · Confirma as lições 31 a 51

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

Página 3 de 5

Placeholder JoyID lock args are 22 bytes when quoting capacityPráticoDe uma correção

When quoting capacity before a wallet is connected, use a placeholder lock shaped like the wallet you expect. A JoyID lock has 22 byte args, 2 bytes more than a secp256k1 lock's 20, so every cell carrying the user's lock needs 2 CKB more occupied capacity. Pass the placeholder (for example args of 22 zero bytes) to the same quote function used after connecting, so the pre-connect total is not lower than what a JoyID user will actually commit.

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

Indexer get_cells order is by script args, not by cell agePráticoDe uma correção

Cells returned by a prefix search on type script args (as findRounds does here) come back in indexer key order, sorted by type args, not by creation time, so taking the first result does not give the newest cell. To get the latest, sort by a field stored in the cell (here the round config's entryStart).

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

Wait for get_indexer_tip to reach the commit block before re-reading cellsPráticoVista outra vez

After get_transaction reports tx_status committed, poll get_indexer_tip until its block_number is at least the transaction's block number before calling get_cells. If you query first, the indexer silently returns the pre-transaction cell set with no error.

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

Check chain-wide script users before consuming a deployed code cellPráticoVerificada pelo dono

Before consuming a deployed code cell, call indexer get_cells across the whole chain with script_search_mode "prefix" and args "0x", once as lock and once as type. Query the cell's data hash with hash_type data, data1 and data2, and for a Type ID cell also its type script hash with hash_type type. Zero results only means no live cell uses the binary right now. Consuming the cell is irreversible, and a Type ID identity cannot be recreated, so treat unused Type ID cells with extra caution.

#Cell deps and script lookup #Indexer queries and cell collection #Type ID and upgrades · Fontes (2) · 2026-10-10

Output type scripts need cell deps too, including the native DAO typeBásicoDe uma correção

CKB runs the type script of every output (not only input locks and input types), so a transaction that creates a native DAO deposit must include the DAO type's code cell (genesis tx0 index 2) as a cell dep, or the node rejects it with ScriptNotFound on Outputs[i].Type. Pre-send checks that only verify deps for input locks will miss this; check every input lock, input type and output type, deduplicated by code_hash and hash_type.

#Cell deps and script lookup #Transaction building and fees · Fontes (1) · 2026-10-05

Relative block number since uses top byte 0x80, not the absolute epoch 0x20PráticoDe uma correção

Under RFC 0017 since encoding, bit 63 marks relative and bits 61 to 62 select the metric (00 is block number), so a relative block count is RELATIVE_BLOCK_FLAG (0x8000000000000000) OR the count, and 256 blocks becomes 0x8000000000000100. In this commit the type script checks since >> 56 == 0x80, so reusing the absolute epoch form (top byte 0x20) is rejected on chain with an error code that does not name the since as the cause.

#Since and time locks · Fontes (2) · 2026-10-02

Verify header_deps against independently fetched headers, not against the tx's own listPráticoDe uma correção

When checking a transaction that uses header_deps for entropy (for example, headers at fixed offsets from a cell's inclusion block), derive the expected headers yourself: get the creating tx with get_transaction, then get_header on its block_hash, then get_header_by_number for the scheduled heights. Only then compare them to the tx's header_deps. Taking the headers from header_deps makes the check circular, since it only confirms the transaction agrees with itself.

#Since and time locks #Network and RPC reliability · Fontes (1) · 2026-10-02

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

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

Página 3 de 5

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.