cadenceonflow-cadence

Does updating/redeploying a smart contract on Flow reset its state on mainnet?


Following this official guide here

https://developers.flow.com/flow/dapp-development/mainnet-deployment#updatere-deploy-a-contract-on-mainnet-using-the-cli

I would like to make some updates to a smart contract I've got on Mainnet and there's a bunch of existing NFTs in there in an array that lives on the contract, would updating the contract via the CLI following the guide above just... erase those NFTs and reset the contract's data?


Solution

  • Great question! Updating a contract only updates the code deployed in the contract. It does not update any objects or other state stored in the contract. This is why you can't do any updates to a contract such as adding or removing fields, changing the type of a field, and other such changes. See the upgrade docs for more information: https://developers.flow.com/cadence/language/contract-updatability