How can I create bin of predicate to use it in TS SDK?

I found in TS SDK docs that I have to use forc build for predicate sway code to get bin code, but after running this command I have in out folder these files

What is best practice to I need to use with saving this bin project ?
In case where I provide just import/export of this file and provide it to new Provider entity it fails with next error

Only way that works for me is to convert this bin to byte array and then provide to constructor of Predicate, but it seems to be bad solution.


@sway if you’re using the abi typegen command to interact with the predicate, then within the autogenerated typescript files, you will already have the hexlified binary that can be passed to a provider. You should be able to access it like so:

import { MyPredicateFactory } from "./predicates";

const bin = MyPredicateFactory.bin;

However, I can appreciate that accessing static properties on a factory class also doesn’t feel like appropriate user experience, we should probably be exporting those from "./predicates/index.ts" also :thinking:.


As @danielbate said, you can use the generated factory class for your Predicate (if you’re using Typegen), or you can also do it manually, as described here:


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