To develop on the Fluence platform, we recommend using the Fluence CLI.
Ensure version compatibility
To ensure seamless operation of all components of the Fluence protocol, it is crucial to maintain version compatibility across all parts. The version of Fluence CLI you use must be compatible with the Nox version you are connecting to.
Keep Fluence CLI up to date
Updating Fluence CLI is the first and most important step in ensuring version compatibility. Use the fluence update command to update Fluence CLI. The allowed parameters for this command include:
dar - version compatible with the current dar environment
kras - version compatible with the current kras environment
stage - version compatible with the current stage environment
main - latest build from the main branch
For example, if you are using the dar environment, run fluence update dar first. You also need to use the --env flag to select the environment or run fluence default env dar within the Fluence project to set the environment as the default for the project.
Ensure compatibility of dependencies
Fluence CLI includes hardcoded versions of all Fluence protocol components that have been tested to work together. In general, everything should work fine if you are using the local Fluence network. However, you may have specified dependencies in the fluence.yaml configuration of your project that do not match the current CLI version. To reset these dependencies to the default versions, run:
bash
复制代码
fluence dep r
Although not necessary, it is a good practice to run this command every time you update CLI to ensure compatibility. Advanced users can run fluence dep v to see all these versions.
Manage Fluence CLI dependencies
Aqua
To install Aqua dependencies for your project, run:
bash
复制代码
fluence dep i
You can install specific Aqua dependencies:
bash
复制代码
fluence dep i @fluencelabs/aqua-lib@0.9.1
To uninstall specific Aqua dependencies, run:
bash
复制代码
fluence dep un @fluencelabs/aqua-lib
You can also edit fluence.yaml directly and then run fluence dep i.
Advanced users should note that the Aqua compiler currently relies on npm as its package manager. If you encounter any issues, refer to the npm documentation. Fluence CLI manages its own version of npm, so there is no need to install npm separately.
Rust
Fluence CLI will attempt to install Rust for you on Linux and macOS. If you are using Windows or CLI fails to install Rust, refer to the official Rust documentation for installation instructions.
Fluence CLI will also install the required Rust toolchain and add the wasm32-wasi target. If you encounter any Rust-related issues, try the following:
Make sure you don't have two Rust installations (e.g., installed via rustup and brew on macOS).
Manually install wasm32-wasi:
bash
复制代码
rustup target add wasm32-wasi
rustup target add wasm32-wasi --toolchain nightly
rustup update
Reinstall Rust if necessary.
Marine and Mrepl
To create and compile your Rust code to WASI and test the generated Wasm modules, you need Marine CLI and Marine REPL. Both components are wrapped by Fluence CLI and lazily loaded from their respective GitHub release versions. To force the download, run:
bash
复制代码
fluence dep i
Advanced users can override the marine and mrepl versions using the marineVersion and mreplVersion properties in the project. If the download fails, Fluence CLI will attempt to build marine and mrepl from source using cargo.
Docker
If you want to use the local Fluence network, Docker is required and useful for testing code before deploying it to remote dar or kras environments. Install Docker Desktop for your operating system following the official Docker documentation. After installation, make sure to run Docker before attempting to set up the local Fluence network using the following command:
bash
复制代码
fluence local up
By following these steps and guidelines, you can set up and maintain a compatible and efficient development environment for Fluence.