CKB Pulse

All lessons · CCC (TypeScript SDK) · Start here · Glossary

Clear the CCC client cache after a sent transaction loses a double spend raceWorkingFrom one fix

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

A CCC client caches the outputs of every transaction it sent, so when that transaction loses a race for the same input and never commits, its change cells still look usable to later builds. This campaign calls client.cache.clear() on every client before rebuilding and confirms candidate cells with getCellLiveNoCache rather than trusting cached state.

Why it matters: Without clearing, the losing client's cache still lists that transaction's change outputs as spendable and its inputs as spent, so rebuilds pick cells that do not exist on chain and the node rejects them.

Pattern

Prefer
for(const c of clients)await c.cache.clear();

Taken from the commit, shortened.

Concepts
Indexer queries and cell collection, Transaction building and fees
Evidence
From one fix: from one project, checked against its commit
First seen
2026-10-29
Last changed
2026-10-29
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 CCC (TypeScript SDK)

All 33 in this topic

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

Cite this lesson
LusoCryptoLabs, "Clear the CCC client cache after a sent transaction loses a double spend race", CKB lessons, https://pulse.lusocryptolabs.com/learned/ccc/clear-the-ccc-client-cache-after-a-sent-transaction-loses-a, CC BY 4.0, last changed 2026-10-29.

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.