Skip to main content
Contracts with an admin address can be migrated to new code versions and have their admin transferred or cleared. These operations are central to the CosmWasm upgrade lifecycle.

Migrating a Contract

Migrate moves a contract to a new code ID while preserving its address and state. The contract must have an admin, and the migration message is passed to the new code’s migrate entry point.
1

Upload the new code

2

Migrate the contract

The migrate message (fourth argument) is contract-defined. It typically handles schema changes, data migrations, or field initialization for the new version.
Only the contract’s admin address can call migrate. The sender must match the admin set during instantiation (or a subsequent updateAdmin call).

Updating the Admin

Transfer admin privileges to a different address:
After this call, only osmo1newadmin... can migrate the contract or change the admin again. The original admin loses all privileges.

Clearing the Admin

Remove the admin entirely, making the contract permanently non-upgradeable:
Clearing the admin is irreversible. The contract can never be migrated or have its admin updated again. Only do this when you are certain the contract should be immutable.

Contract Lifecycle Summary

Next Steps

Querying Contracts

Verify contract metadata and code history after migration.

Gas and Advanced Usage

Gas estimation, custom messages, and the wasm query extension.