Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

replace_bytecode

Replaces class for given contract address. The new_class hash has to be declared in order for the replacement class to execute the code, when interacting with the contract.

  • contract - address specifying which address will be replaced
  • new_class - class hash, that will be used now for given address Returns Result::Ok if the replacement succeeded, and a ReplaceBytecodeError with appropriate error type otherwise

Fully qualified path: snforge_std::cheatcodes::replace_bytecode

pub fn replace_bytecode(
    contract: ContractAddress, new_class: ClassHash,
) -> Result<(), ReplaceBytecodeError>