pub fn compute_bytecode_root(
    ref mut bytecode: Vec<u8>,
    configurables: Option<ContractConfigurables>,
) -> BytecodeRoot 
Expand description

Takes the bytecode of a contract or predicate and configurables and computes the bytecode root.

Arguments

  • bytecode: [Vec] - The bytecode of a contract or predicate.
  • configurables: [Option] - Some configurable values to swap or None.

Returns

  • [b256] - The bytecode root of the contract or predicate.

Reverts

  • When the bytecode is empty.

Examples

use sway_libs::bytecode::{compute_bytecode_root, BytecodeRoot, ContractConfigurables};

fn foo(my_bytecode: Vec<u8>, my_configurables: Option<ContractConfigurables>) {
    let mut my_bytecode = my_bytecode;
    let bytecode_root: BytecodeRoot = compute_bytecode_root(my_bytecode, my_configurables);
    assert(bytecode_root != b256::zero());
}