Compile the current or target project.
The output produced will depend on the project's program type.
contractprojects will produce their bytecode in binary format
scriptprojects will also produce a file containing the hash of the bytecode binary
predicateprojects will also produce a file containing the root hash of the bytecode binary
libraryprojects will also produce the public ABI in JSON format
forc build [OPTIONS]
Print the generated Sway AST (Abstract Syntax Tree)
Name of the build profile to use.
If unspecified, forc will use debug build profile.
Build target to use for code generation
[default: fuel] [possible values: fuel, evm, miden-vm]
Print the computed Sway DCA graph
Treat warnings as errors
Print the finalized ASM.
This is the state of the ASM with registers allocated and optimisations applied.
If set, outputs source file mapping in JSON format
Print help information
Print the generated ASM.
This is the state of the ASM prior to performing register allocation and other ASM optimisations.
Print the generated Sway IR (Intermediate Representation)
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
Outputs json abi with callpaths instead of names for struct and enums
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
Set the log level
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
If set, outputs a binary file representing the script bytes
Offline mode, prevents Forc from using the network when managing dependencies. Meaning it will only try to use previously downloaded dependencies
The directory in which the sway compiler output artifacts are placed.
By default, this is
Path to the project, if not specified, current working directory will be used
Use release build plan. If a custom release plan is not specified, it is implicitly added to the manifest file.
If --build-profile is also provided, forc omits this flag and uses provided build-profile.
Silence all output
Terse mode. Limited warning and error output
Also build all tests within the project
Output the time elapsed over each part of the compilation process
Use verbose output
Compile the sway files of the current project.
$ forc build Compiled script "my-fuel-project". Bytecode size is 28 bytes.
The output produced will depend on the project's program type. Building script, predicate and contract projects will produce their bytecode in binary format
<project-name>.bin. Building contracts and libraries will also produce the public ABI in JSON format
By default, these artifacts are placed in the
Forc.lock file did not yet exist, it will be created in order to pin each of the dependencies listed in
Forc.toml to a specific commit or version.