Automated Address Management
When you publish or upgrade a package, its address (also known as the package ID) is tracked in the Move.lock
file. This bookkeeping is done automatically so that you can avoid recording or updating hex addresses (for example, in the Move.toml
file).
When you publish or upgrade your package on multiple chains (Mainnet, Testnet, Devnet) separate addresses for each chain are tracked for you. This tracking is based on your active environment (run sui client active-env
if unsure). For example, if you set your active environment to an RPC connected to testnet
and publish a package, the Move.lock
records the address for that package and associates it with your active environment (testnet
).
Note that automated address management works for one package published to one or more chains. When you publish or upgrade, address management uses the contents of the package's working directory. If a package is republished to a chain, addresses tracked for the previously published package are overwritten for that chain.
Adopting automated address management for published packages
Previously a published-at
entry was mandatory in the Move.toml
file, which sets the address of the latest published package. It is no longer required if this data is tracked in the Move.lock
file. For an existing package, add the necessary data to the Move.lock
file so that it can be automatically tracked:
- Switch to your active environment for the chain that your package is published on
sui client --switch --env <YOUR-CHAIN-ENVIRONMENT>
- Run the
manage-package
command with the data for your published packagesui move manage-package --environment "$(sui client active-env)" \
--network-id "$(sui client chain-identifier)" \
--original-id 'ORIGINAL-ADDRESS' \
--latest-id 'LATEST-ADDRESS' \
--version-number 'VERSION-NUMBER'ORIGINAL-ADDRESS
should be the address your package was first published at. If you never upgraded your package, this the same address as yourpublished-at
address in theMove.toml
LATEST-ADDRESS
should be the latest package address. If you never upgraded your package, it is the same asORIGINAL-ADDRESS
. If you upgraded your package, this is the same address as your currentpublished-at
address in theMove.toml
.VERSION-NUMBER
is1
if you never upgraded your package. Otherwise, it is a number greater than1
depending on how many times you upgraded your package. In this case, look up the package atLATEST-ADDRESS
to determine the version number.
- Delete the
published-at
line in yourMove.toml
. Your package is now tracked. You can repeat the above steps to track addresses for additional environments.
Package upgrade guidance
-
When upgrading, you need to retrieve the
UpgradeCap
ID of your published package. Automated address management does not track yourUpgradeCap
. -
When upgrading, you first need to set the
[addresses]
value for your package to0x0
in theMove.toml
, and restore its ID with theORIGINAL-ADDRESS
after upgrading.
Troubleshooting
Conflicting published package addresses might happen when the state of package data is inconsistent.
For example, you might have an existing package with a published-at
value in the Move.toml
. The package is re-published for testing purposes, and is now tracked in Move.lock
with automated address management. The address in the Move.toml
and Move.lock
now differ, and there will be an error the next time you try to publish or upgrade the package.
Here are steps to remediate conflicting addresses:
-
If the conflict is in a package you maintain:
- Delete the
published-at
value in yourMove.toml
if this published address is no longer needed - Alternatively, follow the steps to adopt automated address management
- Delete the
-
If the conflict is in a package that you do not maintain (such as a dependency), consider fixing the issue locally with the steps above, or contacting the maintainer to upstream changes.