fuel_contract_message_predicate/
lib.rs

1mod predicate_asm;
2mod script_asm;
3
4use fuel_tx::{ConsensusParameters, Input};
5use sha2::{Digest, Sha256};
6
7// Make the script and predicate bytecode public
8pub use predicate_asm::bytecode as predicate_bytecode;
9pub use script_asm::bytecode as script_bytecode;
10
11// Gets the hash of the message-to-contract script
12pub fn script_hash() -> [u8; 32] {
13    let script = script_asm::bytecode();
14    let mut script_hasher = Sha256::new();
15    script_hasher.update(script);
16    script_hasher.finalize().into()
17}
18
19// Gets the root of the message-to-contract predicate
20pub fn predicate_root(cparams: &ConsensusParameters) -> [u8; 32] {
21    let predicate = predicate_asm::bytecode();
22    let root = Input::predicate_owner(predicate, cparams);
23    root.into()
24}