pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()>
Expand description

Replace the contract code at the specified address with new code.


There are a couple of important considerations which must be taken into account when using this API:

  1. The storage at the code hash will remain untouched. This means that contract developers must ensure that the storage layout of the new code is compatible with that of the old code.

  2. Contracts using this API can’t be assumed as having deterministic addresses. Said another way, when using this API you lose the guarantee that an address always identifies a specific code hash.

  3. If a contract calls into itself after changing its code the new call would use the new code. However, if the original caller panics after returning from the sub call it would revert the changes made by seal_set_code_hash and the next caller would use the old code.


ReturnCode::CodeNotFound in case the supplied code_hash cannot be found on-chain.