pub fn verify_contract_bytecode(contract_id: ContractId, bytecode: Vec<u8>) 
Expand description

Asserts that a contract’s bytecode and the given bytecode match.

Arguments

  • contract_id: [ContractId] - The contract that the bytecode should match.
  • bytecode: [Vec] - The bytecode of the contract.

Reverts

  • When the contract’s bytecode root does not match the passed bytecode.

Examples

use sway_libs::bytecode::verify_contract_bytecode;

fn foo(my_contract_id: ContractId, my_bytecode: Vec<u8>) {
    verify_contract_bytecode(my_contract_id, my_bytecode);
    // This line will only be reached if the contract's bytecode root and the computed bytecode root match.
}