How it works
Under the hood, it deploys a small cleanup contract to the target account and, in a single transaction, calls itsclean method with every key in the account’s state. The cleanup contract is left in place — it is not removed — until you deploy a new contract over it.
How to use
Install NEAR CLI
The State Cleaner is invoked through NEAR CLI, so you need it installed first. If you do not already have it installed, visit the NEAR CLI page.
Install the State Cleaner extension
Install it straight from the GitHub repository:
Requires a Rust toolchain ≥ 1.88.
Run the command
Run the extension in interactive mode and follow the prompts:Or pass everything in one go:
Use an RPC with a larger view-state cap
If the account’s state is large, you may hit:Most public RPCs cap Set the
view_state responses (around 50 KB). Point NEAR CLI at an RPC with a higher cap:rpc_url value to a higher-capacity provider, then re-run the command. Intear’s RPCs work well:- Testnet:
https://testnet-rpc.intea.rs - Mainnet:
https://rpc.intea.rs
(Optional) Verify the bundled wasm
The wasm embedded in the extension isn’t built here — it’s NEAR’s prebuilt
state-manipulation cleanup contract, vendored from near/core-contracts. The extension pins a specific upstream commit, recorded in extension/wasm/state_cleanup.wasm.provenance.To verify that the wasm in the tool matches the wasm from core-contracts, clone the tool and run the verify script. It re-downloads the upstream wasm at the pinned commit and confirms the bundled bytes match: