Inventory CosmWasm instances currently associated with a code ID

A code upload and a contract instance are different records. Before a migration review, list the instances currently associated with the code you are evaluating.

Page through a single code ID

Use a wasmd-compatible TLS gRPC endpoint with reflection in GRPC. Replace 17 with the on-chain code ID. Read the returned contract addresses and continue using pagination.nextKey if present.

grpcurl -d '{"codeId":"17","pagination":{"limit":"25"}}' "$GRPC" cosmwasm.wasm.v1.Query/ContractsByCode

For 26 instances and a page size of 25, a full export requires a second request. Pass the response key unchanged in pagination.key. Record the query height so concurrent migrations do not silently mix two inventories.

Confirm instance-specific configuration

Query ContractInfo for each address you will operate on. Contracts using identical code can have different admins, initialization parameters and balances. A contract that migrated away may appear in historical migration records even though its current code ID has changed. github.com wasmd Query API