Updating unpublished smart contract
Example of updating an unpublished smart contract
One of the features of Acala EVM+ is the ability to verify the expected behaviour of your smart contract before the users can interact with it (before it is published). In the event of the business logic of the contract being broken, it can be updated without the need to redeploy a new version of the smart contract.
We can only update unpublished contracts.
Let's take a simple Echo
smart contract that we deployed to the chain:
As the smart contract was deployed using an EVM account bound to the substrate account, that account can update the bytecode of an unpublished contract. This is because the EVM module considers deployer a maintainer of the smart contract.
The example smart contract has a faulty configuration, where it increments the echoCount
by 2 instead of 1, so we can update the smart contract to be correct and compile it in order to get the new bytecode:
The code can be updated using extrinsics in the Polkadot.js application. The call can be found under Developer menu
in Extrinsics
. Then select evm
in the extrinsics selection dropdown and setCode
call. The arguments passed to it is the address of the unpublished smart contract we are updating and the new bytecode.
Pressing Submit transaction
will send the transaction to update the bytecode of the smart contract. Once you are done with testing it, you can publish your smart contract.
Updating storage layout of your smart contract can result in unexpected behaviour, so only the business logic of the smart contracts should be updated in this way.
Last updated