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

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

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" }