Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Dependencies

Icon LinkDependencies

Forc has a dependency management system which can pull packages using git, ipfs, path, or the community registry. This allows users to build and share Forc libraries.

Icon LinkAdding Dependencies

You can add dependencies manually in your Forc.toml, or by using the forc add command.

Icon LinkUsing forc add

The forc add CLI supports various sources and optional flags:

forc add <dep> [--path <PATH>] [--git <URL> --tag <TAG>] [--ipfs <CID>] [--contract-dep]

Icon LinkAdd Examples

  • From a Git branch:

    forc add custom_lib --git https://github.com/FuelLabs/custom_lib --branch master
  • From a local path:

    forc add custom_lib --path ../custom_lib
  • From IPFS:

    forc add custom_lib --ipfs QmYwAPJzv5CZsnA...
  • From registry (forc.pub):

    forc add custom_lib@0.0.1
  • Add as a contract dependency:

    forc add my_contract --git https://github.com/example/contract --contract-dep

Optional:

  • --salt <HEX> for custom contract salt.
  • --package <NAME> to target a specific package in a workspace.
  • --manifest-path <PATH> to specify a manifest file.
Icon InfoCircle

⚠️ Note: We do not currently support offline mode for projects that use registry sources. Also wildcard declarations (ex: custom_lib = *) to get the latest version available for that package or caret declarations (ex: custom_lib = ^0.1) to get SemVer compatible latest available option for a given dependency is not supported yet.

Once the package is added, running forc build will automatically fetch and resolve the dependencies.

Icon LinkManually Editing Forc.toml

If your Forc.toml doesn't already have a [dependencies] or [contract-dependencies] table, add one. Below, list the package name and its source.

Icon LinkLocal Path

[dependencies]
custom_lib = { path = "../custom_lib" }

Icon LinkIPFS Source

[dependencies]
custom_lib = { ipfs = "QmYwAPJzv5CZsnA..." }

Icon LinkRegistry Source (forc.pub)

[dependencies]
custom_lib = "0.0.1"

Icon LinkRemoving Dependencies

You can remove one or more dependencies using the forc remove command:

forc remove <dep> [--contract-dep] [--package <NAME>] [--manifest-path <PATH>]

Icon LinkRemove Examples

  • Remove from [dependencies]:

    forc remove custom_lib
  • Remove from [contract-dependencies]:

    forc remove my_contract --contract-dep
  • Target a specific package in a workspace:

    forc remove custom_lib --package my_project

Icon LinkUpdating Dependencies

To update dependencies in your Forc directory you can run:

forc update

For path and ipfs dependencies this will have no effect. For git dependencies with a branch reference, this will update the project to use the latest commit for the given branch.