-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: predicate and script deploys (#3266)
* chore: add docs for deploying scripts and predicates * chore: update predicate doc Co-authored-by: Nedim Salkić <[email protected]> * fix tests * fix lint * fix formatting * docs: update docs Co-authored-by: Nedim Salkić <[email protected]> * docs: update docs Co-authored-by: Nedim Salkić <[email protected]> * docs: update docs Co-authored-by: Nedim Salkić <[email protected]> * use `autoStartFuelCore` (with bugfix to `deploy`) * use `autoStartFuelCore` (with bugfix to `deploy`) * chore: delete pretest script in docs snippets * chore: changeset * chore: reimplement pretest script * chore: revert more autostart fuel-core changes * chore: further reverts * doc: add value comment Co-authored-by: Peter Smith <[email protected]> * chore: update snippet * Update .changeset/thirty-parrots-sniff.md --------- Co-authored-by: Nedim Salkić <[email protected]> Co-authored-by: Peter Smith <[email protected]>
- Loading branch information
Showing
8 changed files
with
120 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
--- | ||
|
||
docs: predicate and script deploys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Kill anything running on port 4000 | ||
lsof -t -i:4000 | xargs -r kill | ||
|
||
# Runs a node at port 4000 | ||
pnpm fuels node > /dev/null 2>&1 & | ||
|
||
# Builds projects | ||
pnpm fuels build | ||
|
||
# Deploys projects (needed for loader bytecode) | ||
pnpm fuels deploy | ||
|
||
# Kills the node | ||
lsof -t -i:4000 | xargs -r kill | ||
|
||
# Checks for type errors | ||
pnpm tsc --noEmit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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](../fuels-cli/index.md) and running the [deploy command](../fuels-cli/commands.md#fuels-deploy). | ||
|
||
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](../fuels-cli/index.md) and execute the [deploy command](../fuels-cli/commands.md#fuels-deploy). | ||
|
||
This will perform the following actions: | ||
|
||
1. Compile the predicate using your `forc` version | ||
1. Deploy the built predicate binary to the chain as a blob | ||
1. Generate a new, smaller predicate that loads the deployed predicate's blob | ||
1. 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: | ||
|
||
<<< @/../../docs-snippets/src/guide/predicates/deploying-predicates.test.ts#deploying-predicates{ts:line-numbers} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Deploying Scripts | ||
|
||
In order to optimize the cost of your recurring script executions, we recommend first deploying your script. This can be done using the [Fuels CLI](../fuels-cli/index.md) and running the [deploy command](../fuels-cli/commands.md#fuels-deploy). | ||
|
||
By deploying the script, 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 script. This far reduces the repeat execution cost of the script. | ||
|
||
## How to Deploy a Script | ||
|
||
To deploy a script, we can use the [Fuels CLI](../fuels-cli/index.md) and execute the [deploy command](../fuels-cli/commands.md#fuels-deploy). | ||
|
||
This will perform the following actions: | ||
|
||
1. Compile the script using your `forc` version | ||
1. Deploy the built script binary to the chain as a blob | ||
1. Generate a script that loads the blob that can be used to execute the script | ||
1. Generate types for both the script and the loader that you can use in your application | ||
|
||
We can then utilize the above generated types like so: | ||
|
||
<<< @/../../docs-snippets/src/guide/scripts/deploying-scripts.test.ts#deploying-scripts{ts:line-numbers} |