Contract Upgrade Lifecycle
Neo N3 supports upgrading deployed contracts through the native ContractManagement system. The lifecycle is:
Deploy
Initial deployment creates the contract on-chain:
bash
$NEOXP contract deploy -i chain.neo-express build/MyContract.nef node1Update
Update replaces the contract's NEF and manifest while preserving its storage and hash:
bash
$NEOXP contract update -i chain.neo-express "$CONTRACT_HASH" build/MyContractV2.nef node1When updating:
- The
_deploy(data, update)method is called withupdate = true. - The Solidity constructor logic is skipped (only runs on initial deploy).
- Storage is preserved -- existing state variables retain their values.
- The contract hash remains the same.
Destroy
Remove a contract from the chain (irreversible):
bash
# Via devpack: ContractManagement.destroy() in your contract code
# Or via neo-cli / SDK calls to ContractManagementDANGER
destroy permanently removes the contract and its storage. This cannot be undone. Only include destroy functionality if your contract genuinely needs it, and protect it with proper access control.
Update Smoke Test
The repository includes an automated update smoke test:
bash
make test-deploy-update-smokeThis script:
- Deploys a v1 contract with constructor args
- Updates it to v2
- Verifies that the constructor did not re-run on update
- Verifies that new methods from v2 are callable
