Start here · Glossary · Test yourself · Feed
#Transaction building and fees ✕
52 lessons found. All lessons
Page 1 of 5Next
CKB's send_transaction returns -1107 when the same tx is already in the pool, but -1111 (PoolRejectedRBF) when a different pool tx spends one of its inputs and this tx cannot replace it. Treating -1111 like -1107 makes a client resend a tx whose input is gone and only notice the failure much later. Fiber now reports it as a conflict (failing a funding tx at once) while closing txs keep the old handling.
#Network and RPC reliability #Transaction building and fees · Sources (2) · 2026-11-18
A ccc client records the transactions it sends in its cache, so a claim or sweep the chain dropped or rejected stays there with its outputs usable and its inputs spent, which breaks later sends. Check such transactions with client.getTransactionNoCache and treat an undefined result or status "rejected" as dropped. Rebuild that client's cache from the chain before building new sends, and give automated sends their own ccc client so this rebuild does not touch the account's other pending transactions.
Related to the cache clearing and getTransactionNoCache lessons, but adds a distinct remedy: treat undefined or rejected as dropped, and use a separate client for automated sends to isolate its cache.
#Network and RPC reliability #Transaction building and fees · Sources (1) · 2026-11-17
In flows like Create followed by Arm, save local state right after the first transaction is sent. If you wait until the whole flow finishes, a failure in a later step leaves an on-chain object the user cannot find or cancel. Add the extra fields, such as the descriptor, once the later steps succeed.
#Transaction building and fees #Other · Sources (1) · 2026-11-16
Witnesses are matched to inputs by position: witness i belongs to input i, and a script reading GroupInput witnesses sees the witnesses at its group's input positions. Reordering inputs does not move the witnesses, so after reordering, check and rebuild the witness list so each input's position again holds the intended witness.
#Witnesses and signatures #Transaction building and fees · Sources (1) · 2026-11-16
Every output must hold at least its occupied capacity: (8 for the capacity field + 33 + lock args length, plus 33 + type args length if a type script is present, plus data length) × 10^8 shannons. That is 61 CKB for a plain secp256k1 lock with 20 byte args and 63 CKB for a JoyID lock. A fixed payout or fee output set below the recipient lock's minimum is rejected, so choose a constant at or above the largest minimum among the locks you accept.
#Capacity and cell size #Transaction building and fees · Sources (2) · 2026-11-15
Put the type script's witness data in WitnessArgs.input_type of each input it guards (the type script reads the first witness of its own input group), so the lock field stays free for the wallet's signature and one signature can cover several such inputs. If the change left after a fixed fee is below a plain cell's minimum occupied capacity, add it to an existing output whose scripts accept extra capacity; if there is no such output, refuse the build instead of creating a cell that cannot exist.
#Witnesses and signatures #Transaction building and fees #Capacity and cell size · Sources (1) · 2026-11-14
`full` is a VM mode, and by default ckb-debugger runs only input 0's lock, which may be an always-success lock. To check a whole transaction, enumerate every input lock, input type and output type group, run each with --script-group-type/--cell-type/--cell-index, and sum the cycles. Pair each accepted case with a control that must fail with an exact error code.
#Testing and devnet #Transaction building and fees · Sources (1) · 2026-11-14
When off-chain JS encodes or derives cell data that a Rust type script decodes or re-derives byte for byte, test the JS against JSON vectors generated by the Rust code, using a distinct value in every field so a wrong offset fails. Mirror the contract's validation refusals and its exact ordering and rounding: BTreeMap ascending key order, BigInt floor division with the dust going to fixed indices, and merging duplicates before dividing. The chain only returns a bare error code, so only this off-chain check can tell you which rule failed.
#Data encoding (molecule, hex, bigints) #Testing and devnet #Transaction building and fees · Sources (2) · 2026-11-13
In phase one, output i must mirror deposit input i (same capacity, lock and DAO type), with its data set to the deposit block number as a u64 LE, and the deposit block hash must be in header_deps. Put any fee-paying input and output after all deposits. A custom lock that enforces a full 180-epoch term before phase one pushes payout to the next cycle boundary (about deposit + 360 epochs, roughly 60 days).
#Since and time locks #Transaction building and fees #Cell deps and script lookup · Sources (1) · 2026-11-13
A pre-sign checker that reuses the builder's assumptions will miss the builder's bugs, so make it compare every field the script compares, outputs_data included. When you add data to an output, count those bytes in its occupied capacity (8 + data + lock + type). Replay refused transactions in ckb-debugger against the deployed binaries to confirm the fix.
#Capacity and cell size #Transaction building and fees #Testing and devnet · Sources (1) · 2026-11-11
The built-in CKB indexer can trail the chain tip, so cells it returns may be stale. Before signing, compare the block_number from get_indexer_tip with the height from get_tip_header, show a notice when the gap is large, and refuse to sign while it is. daowow flags the indexer as lagging when it is more than 8 blocks behind, and its entry, refund and claim guards refuse to proceed in that state.
#Indexer queries and cell collection #Network and RPC reliability #Transaction building and fees · Sources (1) · 2026-11-10
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 · Sources (1) · 2026-11-10
Page 1 of 5Next
Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.