CKB Pulse

All lessons · Developer tooling · Start here · Glossary

ckb-cli tx init overwrites an existing tx file with an empty skeletonWorkingFrom one fix

From one fix · Check: right · Checked 2026-11-19

`ckb-cli tx init --tx-file` creates a new empty transaction file and exits 0, so running it on a prepared transaction silently destroys that transaction. For a prebuilt transaction, write ckb-cli's tx-file wrapper ({transaction, multisig_configs, signatures}) yourself and go straight to `tx info` and `tx sign-inputs`.

Why it matters: Running `tx init` on a prepared transaction file replaces it with an empty skeleton and still reports success, so the transaction is lost and the later steps produce no result.

Pattern

Prefer
fs.writeFileSync(outFile, JSON.stringify({ transaction: tx, multisig_configs: {}, signatures: {} }, null, 2));

Taken from the commit, shortened.

Concepts
Transaction building and fees, Witnesses and signatures
Evidence
From one fix: from one project, checked against its commit
First seen
2026-09-23
Last changed
2026-09-23
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (1)

More about Developer tooling

All 35 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "ckb-cli tx init overwrites an existing tx file with an empty skeleton", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/ckb-cli-tx-init-overwrites-an-existing-tx-file-with-an-empty, CC BY 4.0, last changed 2026-09-23.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.