Clean contract state with NEAR CLI JS
- Compile the state-cleanup contract
make all
- Deploy the state-cleanup contract to the account (e.g. example.near)
near deploy example.near ./res/state_cleanup.wasm --network-id mainnet
- View the contact state and you can find the state keys with base64 encoding
near storage example.near --finality optimistic --network-id mainnet
- Clean the state keys
near call example.near clean '{"keys":[<base64 state keys>]}' --network-id mainnet --account-id example.near --gas 300000000000000
Sometimes you may meet the error State of contract example.near is too large to be viewed. This is RPC issue, so you need to use the RPC that allows unlimited view
NEAR_MAINNET_RPC=https://beta.rpc.mainnet.near.org near storage example.near --finality optimistic --network-id mainnet