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.

De uma correção

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

Página 8 de 13

A rejected or unknown get_transaction status does not make a signed transaction deadPráticoDe uma correção

A node reporting a transaction you sent as rejected or unknown does not prove it is dead: one node's answer is not proof, and while all its inputs are live the signed bytes could still be rebroadcast by someone and commit. Only release its reserved inputs if a later transaction is guaranteed to conflict with it (here a shared pool cell every later action must spend, so at most one can commit), and also require that every input is still live, that the status is still rejected or unknown when rechecked after the input reads, and that the submission is old enough (2 minutes here), behind an explicit confirmation.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-10-26

Finding cells of a ckb_js_vm JS contract needs a second indexer prefix searchPráticoDe uma correção

A cell that runs a JS contract carries the ckb_js_vm script as its lock or type. Its args are 2 flag bytes, then the contract's 32 byte code hash, then its hash type byte (data 0, type 1, data1 2, data2 4). A get_cells prefix search on the contract's own code_hash finds none of these cells, so also run a prefix search on the ckb_js_vm script with args set to flags plus code hash plus hash type byte, and merge the results. With 0x0000 as the flags, that search only matches cells whose flags are zero.

#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-25

Omnilock owner signing needs an 85 byte zeroed witness lock placeholderPráticoDe uma correção

For an Omnilock cell spent in owner (secp256k1) mode, the WitnessArgs.lock is an 85 byte OmniLockWitnessLock (a 20 byte molecule header 0x5500000010000000550000005500000041000000 plus the 65 byte signature), so the sighash digest must be computed with an 85 byte zeroed placeholder (e.g. CCC prepareSighashAllWitness(lock, 85, client)). A digest taken over the usual 65 byte secp256k1 placeholder does not verify, which the test confirms against a real testnet spend.

#Witnesses and signatures #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-23

Headless EIP-6963 test wallet for driving the CCC connector in PlaywrightPráticoDe uma correção

To drive CCC's real EIP-6963 connector and EVM/Omnilock signing in headless Playwright, inject a minimal EIP-1193 provider with page.addInitScript passed as a string, because transpiled function sources carry helpers such as __name that the page lacks. The provider answers eth_requestAccounts, eth_accounts and personal_sign, stubs on and removeListener, and announces itself on eip6963:announceProvider, also whenever eip6963:requestProvider fires. Signing runs in Node through page.exposeFunction so the key never enters the page, and personal_sign must return r‖s‖v with v = 27 + recovery id; noble-curves 2.x sign with format "recovered" yields recovery‖r‖s, so reorder it with hexFrom(bytesConcat(recovered.slice(1, 65), [recovered[0] + 27])) and check it against ccc.verifyMessageEvmPersonal.

#Testing and devnet #Witnesses and signatures · Fontes (1) · 2026-10-22

Passing a pipe to a spawned child script via a zero-terminated inherited_fds listAvançadoDe uma correção

When a lock spawns a verifier script from a cell dep with ckb-std 1.1.0 syscalls::spawn, it creates a pipe and passes the read fd in SpawnArgs.inherited_fds as an array ending in 0. After writing the full request, the parent closes write_fd so the child's read returns 0 or OtherEndClosed (end of input), then uses syscalls::wait(pid) == 0 as the verification result.

#Cell deps and script lookup #Other · Fontes (1) · 2026-10-22

JoyID lock witness outputType may carry a subkey proof, so type script data must move elsewherePráticoDe uma correção

When the funding wallet uses the JoyID lock, its WitnessArgs outputType may carry a subkey unlock proof, so do not put your own type script data in that witness's outputType. Place the type script action in another witness index and align the related output index with it. Size the fee estimate's signature placeholder for JoyID's larger witness (openswap uses 1000 bytes) instead of the 65 byte secp256k1 size.

#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-10-22

Release a stuck signed transaction's inputs only after one input is spent elsewherePráticoDe uma correção

A signed CKB transaction that is not committed (not pending, proposed or sent) is still valid and can be broadcast by anyone while all its inputs are live, so do not release its input reservations yet. Release them only after a committed-state live-cell check shows at least one input spent (a spend still in the tx pool does not count), and a second status check confirms the transaction still has not committed. A conflicting spend can still be reorganized away, so require the operator to acknowledge that risk.

#Transaction building and fees #Indexer queries and cell collection #Network and RPC reliability · Fontes (2) · 2026-10-22

Keep at least 61 CKB in the change cell when sending from a secp256k1 walletBásicoDe uma correção

A plain secp256k1_blake160 cell occupies 61 CKB, so when a wallet sends X it must keep at least 61 CKB (the occupied capacity of its own lock) in the change cell, plus the fee, and refuse the send otherwise. The recipient output must also be at least the occupied capacity of the recipient's lock, never less than 61 CKB for a plain address. Enforce the change floor in the transaction builder, and use extra headroom (this runner uses threshold >= amount + 100) for automatic sweeps so fee and change always fit.

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

Carry type script and data into the output when spending a lock-only custody cellPráticoDe uma correção

When a custom lock's spend rebuilds an output from an input cell that may carry a type script (a UDT held in custody, say), copy cell.cellOutput.type and cell.outputData into the output and change only the lock; writing outputsData "0x" with no type burns or strands the token. Add the type script's cell deps to the transaction before signing, because the signature covers the cell deps and callers cannot append them afterwards, and refuse to build the spend if a typed cell comes without them. If the lock also constrains who gets the capacity (as Tranfr's recipient claim does today), follow that rule instead of a plain copy.

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

Use getCellLive, not getCell, when a cell's current state matters in CCCPráticoDe uma correção

In CCC, client.getCell(outPoint) can also return a cell that has already been spent, so status checks built on it report claimed or reclaimed cells as still active. Use client.getCellLive(outPoint, true) and treat an undefined result as "not found or already spent".

#Indexer queries and cell collection · Fontes (1) · 2026-10-20

Keep other WitnessArgs fields when signing sighash_all in testsPráticoDe uma correção

When a test signer for the secp256k1 sighash_all lock fills the first witness of a script group, it should parse the existing WitnessArgs (for example one with data in output_type) and replace only the lock field: zeroed to 65 bytes while hashing, then set to the signature. Building a fresh WitnessArgs drops output_type or input_type data that a type script reads, and sighash_all hashes the whole first witness with only the lock zeroed, so those fields must already be in place when hashing.

#Witnesses and signatures #Testing and devnet · Fontes (1) · 2026-10-20

Recognising a Nervos DAO deposit cell referenced as a stake cell depPráticoDe uma correção

A Nervos DAO deposit cell has the DAO type script (code hash 0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e, hash_type type, empty args) and 8 zero bytes of data; a withdrawing cell has the same type script but the deposit block number as data. A contract that accepts one as a cell dep must check code hash, hash_type, empty args and data == 8 zero bytes, since the DAO script does not run for a dep. For the same reason a ckb_testtool test can create such cells directly with the DAO type script and zero data, without deploying the DAO binary.

#Cell deps and script lookup #Testing and devnet · Fontes (1) · 2026-10-20

Página 8 de 13

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.