Skip to content
Pre-Release: Fe is under active development. This documentation covers the upcoming release. Follow progress on GitHub

Dependencies

Dependencies allow you to use code from other ingots in your project. Fe supports both local path dependencies and remote git dependencies.

Add dependencies to your fe.toml:

[ingot]
name = "my_project"
version = "1.0.0"
[dependencies]
utils = "../shared/utils"
token_lib = { source = "https://github.com/example/token-lib.git", rev = "a1b2c3d4e5f6" }

Reference ingots on your local filesystem:

[dependencies]
my_lib = "../path/to/my_lib"
[dependencies]
my_lib = { path = "../path/to/my_lib" }

Both forms are equivalent. The path is relative to your project’s fe.toml.

my-workspace/
├── contracts/
│ ├── fe.toml
│ └── src/lib.fe
└── shared/
├── utils/
│ ├── fe.toml
│ └── src/lib.fe
└── types/
├── fe.toml
└── src/lib.fe
contracts/fe.toml
[ingot]
name = "contracts"
version = "1.0.0"
[dependencies]
utils = "../shared/utils"
types = "../shared/types"

Pull ingots from git repositories:

[dependencies]
token_lib = { source = "https://github.com/example/token-lib.git", rev = "abc1234" }
FieldDescription
sourceGit repository URL
revGit commit hash (full or abbreviated)

Note: Only commit hashes are supported for rev. Tags and branch names are not allowed because Fe does not yet support lock files. Pinning to exact commits ensures reproducible builds.

FieldDescription
pathSubdirectory within the repository containing the ingot

Pin to a specific commit:

[dependencies]
lib = { source = "https://github.com/org/repo.git", rev = "a1b2c3d4" }

Use a subdirectory in the repository:

[dependencies]
contracts = { source = "https://github.com/org/monorepo.git", rev = "e7f8a9b0c1d2", path = "packages/contracts" }

Once declared, import from dependencies using their name:

// Import from the 'utils' dependency
use utils::calculate_fee
use utils::SafeMath
// Import from the 'token_lib' dependency
use token_lib::ERC20
use token_lib::Transfer

The dependency name in fe.toml becomes the root of the import path.

The name you give a dependency determines its import path:

[dependencies]
# This ingot is imported as 'helpers'
helpers = "../some/path/to/utils"
// Import using the name 'helpers', not the directory name
use helpers::some_function

If two dependencies require different versions of the same ingot, you may encounter conflicts. Strategies to resolve:

  • Update dependencies to use compatible versions
  • Use path dependencies to control exact versions
  • Contact dependency maintainers about version compatibility
Dependency TypeSyntax
Local (simple)name = "path/to/ingot"
Local (explicit)name = { path = "path/to/ingot" }
Git remotename = { source = "url", rev = "ref" }
Git with pathname = { source = "url", rev = "ref", path = "subdir" }