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

**URL:** <https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550>\
**Category:** TypeScript SDK\
**Created:** [May 5, 2023, 9:13pm UTC](https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550 "2023-05-05T21:13:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elena](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elena](https://forum.fuel.network/u/elena)\
**Post date:** [May 5, 2023, 9:13pm UTC](https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550/1 "2023-05-05T21:13:08Z")

</div>

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](https://github.com/FuelLabs/fuels-ts/blob/master/packages/predicate/src/predicate.test.ts#L11)

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

---

<div class="post-metadata">

**Author:** ![anderson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/anderson/32/320_2.png) [@anderson](https://forum.fuel.network/u/anderson)\
**Post date:** [May 6, 2023, 1:17pm UTC](https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550/2 "2023-05-06T13:17:55Z")

</div>

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](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/using-generated-types.html#using-generated-predicate-types)

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

> <https://github.com/FuelLabs/fuels-ts/blob/64a69a10fb12b927f62f190025145098569de40b/packages/abi-typegen/src/utils/collectBinFilePaths.ts#LL29C52-L29C52>

---

<div class="post-metadata">

**Author:** ![elena](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@elena](https://forum.fuel.network/u/elena)\
**Post date:** [May 8, 2023, 6:42pm UTC](https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550/3 "2023-05-08T18:42:46Z")

</div>

thank you! I was indeed trying to do it manually

---

<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:** [May 29, 2023, 2:43pm UTC](https://forum.fuel.network/t/how-to-obtain-the-predicate-bytecode-to-pass-into-predicate-in-frontend/2550/4 "2023-05-29T14:43:27Z")

</div>

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