Skip to content
This guide targets Fe 26.5. Fe is not production-ready. Install Fe 26.5

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 = "0123456789abcdef0123456789abcdef01234567" }

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 = "0123456789abcdef0123456789abcdef01234567" }
FieldDescription
sourceGit repository URL
revFull 40-character git commit hash

Note: rev must be a full 40-character commit hash (as printed by git rev-parse HEAD). Abbreviated hashes, tags, and branch names are rejected, and there is no separate key for tags or branches. Because Fe does not yet support lock files, the exact commit is what makes builds reproducible.

FieldDescription
pathSubdirectory within the repository containing the ingot

Depend on a specific commit:

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

Use a subdirectory in the repository:

[dependencies]
contracts = { source = "https://github.com/org/monorepo.git", rev = "0123456789abcdef0123456789abcdef01234567", 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

A dependency’s unsafe code (its unsafe { .. } blocks, unsafe fn bodies and unsafe impls) may only run if you trust the dependency. Grant trust with allow_unsafe = true:

[dependencies]
my_lib = { path = "../my_lib", allow_unsafe = true }

Your own ingot, workspace members, core and std are always trusted. A trusted dependency’s own allow_unsafe entries extend trust to its dependencies; an untrusted one grants nothing. Only use counts: calling an untrusted dependency’s safe functions needs no trust, and fe check, fe build and fe test report an error only at a call in your code that reaches unsafe code of an untrusted dependency.

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 = "<40-hex commit>" }
Git with pathname = { source = "url", rev = "<40-hex commit>", path = "subdir" }
Trust unsafe codename = { path = "path/to/ingot", allow_unsafe = true }