What difference between creating predicate instance like "load_from" and "new"?

Hi guys
What difference between creating predicate instances like that

let predicate = Predicate::new(code) // and which code I should pass here?

and that

let predicate = Predicate::load_from("./out/debug/predicate.bin").unwrap();

::load_from loads the contents of the given file as the predicate code, while ::new accepts Vec<u8> as the code. The code is the same, the difference is just who does the predicate .bin reading – the user or the SDK.

You can find an example using ::load_from here: fuels-rs/lib.rs at 358364cefdb02a2d7835be03af1e810f3a6d64f5 · FuelLabs/fuels-rs · GitHub

Here is an example using ::new:

      name = "MyPredicate",
      abi = "predicate_basic/out/debug/predicate_basic-abi.json"

  let path_to_predicate_binary = "predicate_basic/out/debug/predicate_basic.bin";

  let the_predicate_code = std::fs::read(path_to_predicate_binary)?;

  let predicate = MyPredicate::new(the_predicate_code);
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.