Back to Fuels Ts

Deploying Predicates

apps/docs/src/guide/predicates/deploying-predicates.md

0.103.01.1 KB
Original Source

Deploying Predicates

In order to optimize the cost of your recurring predicate executions, we recommend first deploying your predicate. This can be done using the Fuels CLI and running the deploy command.

By deploying the predicate, its bytecode is stored on chain as a blob. The SDK will then produce bytecode that can load the blob on demand to execute the original predicate. This far reduces the repeat execution cost of the predicate.

How to Deploy a Predicate

To deploy a predicate, we can use the Fuels CLI and execute the deploy command.

This will perform the following actions:

  1. Compile the predicate using your forc version
  2. Deploy the built predicate binary to the chain as a blob
  3. Generate a new, smaller predicate that loads the deployed predicate's blob
  4. Generate types for both the predicate and the loader that you can use in your application

We can then utilize the above generated types like so:

<<< @./snippets/deploying-predicates.ts#full{ts:line-numbers}