LiçõesO 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
AnteriorPágina 10 de 15Seguinte
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
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
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
Treat a cell as a Nervos DAO deposit only if its type script exactly matches the DAO type script and its data is exactly 8 zero bytes. The DAO type script has code hash 0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e, hash_type type and empty args. A phase one withdrawing cell has the same type script but a nonzero block number in its 8 data bytes, so it fails this check, as do data of any other length and look alike type scripts.
joined with the ckb-service-runner card teaching the same check
#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-20
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
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
When decoding a molecule table by hand (here, the CSR registry cell data), check that the leading u32 total size equals the data length, derive the field count as first_offset/4 - 1, and require first_offset == 4 + 4*count and ascending offsets. Reject a field count different from the schema; this parser is strict and does not accept extra trailing fields, so truncated, padded or extended tables raise ValueError, as the tests show.
table header validation, distinct from WitnessArgs encoding lesson
#Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-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.
#Transaction building and fees #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-17
To show a CKB address balance, convert the address to a lock script (ckb-sdk-utils addressToScript returns camelCase codeHash/hashType) and pass it to the indexer RPC get_cells_capacity with snake_case fields (code_hash, hash_type, args) and script_type "lock". The returned capacity is a hex shannon string, so parse it with BigInt and divide by 10^8 for CKB.
#Indexer queries and cell collection #Data encoding (molecule, hex, bigints) · Fontes (1) · 2026-10-15
Fiber RPC returns scripts as { code_hash, hash_type, args }, but CCC's ScriptLike expects { codeHash, hashType, args }. In this commit a Fiber shaped lock was passed to a CCC based sweep as if it were a ccc.ScriptLike and the sweep failed, so map the fields explicitly before handing the script to CCC.
#Data encoding (molecule, hex, bigints) #Channels and payments · Fontes (1) · 2026-10-14
CCC's Transaction.getSignHashInfo hashes whatever is currently in the witness, so after a signature is filled in it no longer gives the signed message. To verify a signature (for example with ccc.recoverMessageSecp256k1), clone the tx and reset witness 0's lock to the zero placeholder of the same length that was used at signing time.
#Witnesses and signatures #Testing and devnet · Fontes (1) · 2026-10-14
In @ckb-ccc/core, the ClientPublicTestnet constructor takes an options object, so a custom RPC endpoint must be given as { url: rpcUrl } rather than as a bare string argument. This commit corrects the bare string calls in a deploy script to the object form.
#Network and RPC reliability · Fontes (1) · 2026-10-13
AnteriorPágina 10 de 15Seguinte
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.