# What difference between creating predicate instance like "load\_from" and "new"?

**URL:** <https://forum.fuel.network/t/what-difference-between-creating-predicate-instance-like-load-from-and-new/2047>\
**Category:** Sway\
**Created:** [March 16, 2023, 10:16am UTC](https://forum.fuel.network/t/what-difference-between-creating-predicate-instance-like-load-from-and-new/2047 "2023-03-16T10:16:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fuel/32/1677_2.png) [@fuel](https://forum.fuel.network/u/fuel)\
**Post date:** [March 16, 2023, 10:16am UTC](https://forum.fuel.network/t/what-difference-between-creating-predicate-instance-like-load-from-and-new/2047/1 "2023-03-16T10:16:55Z")

</div>

Hi guys  
What difference between creating predicate instances like that

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

```

and that

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

```

---

<div class="post-metadata">

**Author:** ![sarah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/sarah/32/13_2.png) [@sarah](https://forum.fuel.network/u/sarah)\
**Post date:** [March 17, 2023, 3:49pm UTC](https://forum.fuel.network/t/what-difference-between-creating-predicate-instance-like-load-from-and-new/2047/2 "2023-03-17T15:49:41Z")

</div>

`::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](https://github.com/FuelLabs/fuels-rs/blob/358364cefdb02a2d7835be03af1e810f3a6d64f5/examples/predicates/src/lib.rs#L53)

Here is an example using `::new`:

```rust
 abigen!(Predicate(
      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);

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [April 7, 2023, 11:50am UTC](https://forum.fuel.network/t/what-difference-between-creating-predicate-instance-like-load-from-and-new/2047/3 "2023-04-07T11:50:39Z")

</div>

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