How to obtain the predicate bytecode to pass into Predicate in frontend?

How can I obtain the predicate bytecode to use as input for a Predicate in Typescript, like is done in this snippet? fuels-ts/predicate.test.ts at master · FuelLabs/fuels-ts · GitHub

The predicate address seems to be the Predicate root that is given after running forc build, but don’t know where that bytecode hex comes from

When you execute forc build, you’ll notice a .bin inside the out/debug directory. To get the bytecode, you need to hexlify the contents of this .bin file.

You can use the Typegen to generate all the boilerplate files with the bytecode in place:

  1. Generating Types for Predicates
  2. Using Generated Predicate Types

But if you want to do it manually, this is how it is done internally:

3 Likes

thank you! I was indeed trying to do it manually

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