Forc Deploy

Icon Linkforc-deploy

Build output file options

Icon LinkUSAGE:

forc deploy [OPTIONS] [--] [SIGNING_KEY]

Icon LinkARGS:

<SIGNING_KEY> Set the key to be used for signing

Icon LinkOPTIONS:

--asm <ASM>..>

Print the generated ASM (assembler).

Possible values that can be combined: - virtual: initial ASM with virtual registers and abstract control flow. - allocated: ASM with registers allocated, but still with abstract control flow. - abstract: short for both virtual and allocated ASM. - final: final ASM that gets serialized to the target VM bytecode. - all: short for virtual, allocated, and final ASM.

[possible values: virtual, allocated, abstract, final, all]

--ast

Print the generated Sway AST (Abstract Syntax Tree)

--build-profile <BUILD_PROFILE>

The name of the build profile to use

[default: release]

--bytecode

Print the bytecode. This is the final output of the compiler

--dca-graph <DCA_GRAPH>

Print the computed Sway DCA graph. DCA graph is printed to the specified path. If specified '' graph is printed to stdout

--dca-graph-url-format <DCA_GRAPH_URL_FORMAT>

Specifies the url format to be used in the generated dot file. Variables {path}, {line} {col} can be used in the provided format. An example for vscode would be: "vscode://file/{path}:{line}:{col}"

--default-salt

Generate a default salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract. Useful for CI, to create reproducible deployments

--default-signer

Sign the transaction with default signer that is pre-funded by fuel-core. Useful for testing against local node

-g, --output-debug <DEBUG_FILE>

Create a file containing debug information at the provided path. If the file extension is .json, JSON format is used. Otherwise, an ELF file containing DWARF is emitted

--gas-price <PRICE>

Gas price for the transaction

-h, --help

Print help information

--ipfs-node <IPFS_NODE>

The IPFS Node to use for fetching IPFS sources.

Possible values: PUBLIC, LOCAL, <GATEWAY_URL>

--ir

Print the generated Sway IR (Intermediate Representation)

--json-abi

By default the JSON for ABIs is formatted for human readability. By using this option JSON output will be "minified", i.e. all on one line without whitespace

--json-abi-with-callpaths

Outputs json abi with callpaths instead of names for struct and enums

--json-storage-slots

By default the JSON for initial storage slots is formatted for human readability. By using this option JSON output will be "minified", i.e. all on one line without whitespace

--locked

Requires that the Forc.lock file is up-to-date. If the lock file is missing, or it needs to be updated, Forc will exit with an error

--manual-signing

Sign the deployment transaction manually

--maturity <MATURITY>

Block height until which tx cannot be included

[default: 0]

--max-fee <MAX_FEE>

Max fee for the transaction

--metrics-outfile <METRICS_OUTFILE>

Output compilation metrics into file

--no-encoding-v1

Disable the "new encoding" feature

--node-url <NODE_URL>

The URL of the Fuel node to which we're submitting the transaction. If unspecified, checks the manifest's network table, then falls back to http://127.0.0.1:4000

You can also use --target or --testnet to specify the Fuel node.

[env: FUEL_NODE_URL=]

-o, --output-bin <BIN_FILE>

Create a binary file representing the script bytecode at the provided path

--offline

Offline mode, prevents Forc from using the network when managing dependencies. Meaning it will only try to use previously downloaded dependencies

--output-directory <OUTPUT_DIRECTORY>

The directory in which the sway compiler output artifacts are placed.

By default, this is <project-root>/out.

--override-storage-slots <JSON_FILE_PATH>

Override storage slot initialization.

By default, storage slots are initialized with the values defined in the storage block in the contract. You can override the initialization by providing the file path to a JSON file containing the overridden values.

The file format and key values should match the compiler-generated*-storage_slots.json file in the output directory of the compiled contract.

Example: forc deploy --override-storage-slots my_override.json

my_override.json: [ { "key": "<key from out/debug/storage_slots.json>", "value": "0000000000000000000000000000000000000000000000000000000000000001" } ]

-p, --path <PATH>

Path to the project, if not specified, current working directory will be used

--reverse-order

Output build errors and warnings in reverse order

--salt <SALT>

Optional 256-bit hexadecimal literal(s) to redeploy contracts.

For a single contract, use --salt <SALT>, eg.: forc deploy --salt 0x0000000000000000000000000000000000000000000000000000000000000001

For a workspace with multiple contracts, use --salt <CONTRACT_NAME>:<SALT> to specify a salt for each contract, eg.:

forc deploy --salt contract_a:0x0000000000000000000000000000000000000000000000000000000000000001 --salt contract_b:0x0000000000000000000000000000000000000000000000000000000000000002

--script-gas-limit <SCRIPT_GAS_LIMIT>

Gas limit for the transaction

-t, --terse

Terse mode. Limited warning and error output

--target <TARGET>

Use preset configurations for deploying to a specific target.

You can also use --node-url or --testnet to specify the Fuel node.

Possible values are: [beta-1, beta-2, beta-3, beta-4, local]

--testnet

Use preset configuration for the latest testnet.

You can also use --node-url or --target to specify the Fuel node.

--time-phases

Output the time elapsed over each part of the compilation process

--unsigned

Deprecated in favor of --default-signer

-V, --version

Print version information

EXAMPLES:

Icon LinkDeploy a single contract

forc deploy bc09bfa7a11a04ce42b0a5abf04fd437387ee49bf4561d575177e2946468b408

Icon LinkDeploy a single contract from a different path

forc deploy bc09bfa7a11a04ce42b0a5abf04fd437387ee49bf4561d575177e2946468b408 --path {path}

Icon LinkDeploy to a custom network

forc deploy --node-url https://beta-5.fuel.network/graphql

Icon LinkEXAMPLE

You can use forc deploy, which triggers a contract deployment transaction and sends it to a running node.

Alternatively, you can deploy your Sway contract programmatically using fuels-rs Icon Link, our Rust SDK.

You can find an example within our fuels-rs book Icon Link.