Let's understand the end-to-end functionality of Fluence through a complete example of a "Hello World" Fluence cloud application, which includes the following steps:
- Create a Fluence Cloud Function project using the Fluence CLI.
- Create the "Hello World" example and compile it into Wasm.
- Distribute the Wasm module to a provider.
- Execute your Fluence Functions Hello World application.
But first, let's set up.
Setup
The recommended way to interact with the Fluence serverless network is to use the Fluence CLI. The CLI provides full lifecycle management for Fluence functions, as well as tools and development dependencies. If you haven't installed the Fluence CLI yet, please use the installation script provided below or refer to the "Setup" section.
curl -qsL https://raw.githubusercontent.com/fluencelabs/cli/main/install.sh | bash
Note
Currently, the Fluence CLI does not support the Windows operating system, but it does support the Windows Linux Subsystem (WLS).
Information
During the installation process, you may need to provide sudo access to set up symbolic links for the binary files. Alternative installation methods can be found in the Readme.
After the installation is complete, use "fluence update stable" to update the CLI and check the version:
fluence --version
@fluencelabs/cli/0.15.10 darwin-arm64 node-v18.19.1
If you get the above CLI version or a higher version, you can proceed.
Hello World
After installing the Fluence CLI, let's create our hello world project:
fluence init hello-fluence
You will be prompted to choose from different scaffold templates:
? Select template (Use arrow keys)
❯ quickstart
minimal
ts
js
Select the default quickstart template and continue with the default network prompt (kras). The Fluence CLI will now scaffold a project using the quickstart template and the kras test network. Since this is your first time using the Fluence CLI, it may download and install a few dependencies. Once the project is successfully installed, you should see a message similar to the following:
Successfully initialized Fluence CLI project template at /hello-fluence
Now, navigate to the hello-fluence directory and explore the project as you wish. Our next step is to run the hello world command:
fluence run -f 'helloWorldRemote("Fluence")' --quiet
This will produce the following response:
"Hi, Fluence"
Congratulations! You have just created your first Fluence project and executed your first Hello World on a remote peer on the dar test network. We will revisit our Hello World project in the Quickstart section.