Rust Developer Guide
For Rust smart contracts, any no_std
compatible crate (e.g., rand
, alloc
) can be used. Standard library crates are not supported. Verified libraries can be found on crates.io.
Prerequisites
Before getting started, ensure you have the following dependencies installed on your system:
Clang and CMake: Install these if they are not already on your system.
For macOS users, LLVM can be installed via Homebrew:
Install Fluent Scaffold CLI tool
To install the Fluent scaffold CLI tool, run the following command in your terminal:
To create a project, run the following in your terminal:
After installing the Fluent build tool, you can initialize a new project and choose the Rust
option to bootstrap the starter project.
Project Structure
Getting Started
In this guide, we will be working with the lib.rs
file located in the src
folder. The structure for any Rust smart contract will be as follows
lib.rs
This snippet shows how simple it is to interact with the Fluent VM: just call the SDK, initialize your contract, add the functions, and, if needed, define a custom deployment process. For an in-depth look, check this guide.
Compiling the Rust Smart Contract
Understanding the deployment process starts with comprehending the role of the Makefile. This file compiles Rust code into Wasm & rWasm and generates the necessary binaries that will be embedded in a tx for deployment.
Executing this command compiles the code and generates a file named lib.wasm
in the bin
directory.
Deploying the Contract
To deploy contract, use gblend cli:
Upon successful deployment, the receipt of your deployment transaction will be displayed, confirming the smart contract deployment on Fluent using the Fluent SDK.
To view your deployed Fluent contract, navigate to the Fluent Devnet Explorer. From there, you can input your contract address to explore your deployed contract.
Last updated