Using gblend
Using gblend
gblend is a specialized Foundry forge wrapper designed for hybrid Solidity and WebAssembly (WASM) smart contract development on Fluent Network. It seamlessly integrates Rust-based WASM contracts with traditional Solidity development workflows.
The CLI usage is nearly identical to standard Forge, with a few Fluent-specific extensions. For example, to verify WASM contracts, you must pass the --wasm flag.
- WASM Support: Native support for WASM contract compilation and deployment
- Enhanced Verification:
--wasmflag for verifying WASM contracts - Custom REVM: Support for the fluentbase REVM implementation.
Getting Started
1. Create a New Project
# Create a hybrid Solidity + WASM project
gblend init my-project
# Navigate to project
cd my-project
When creating a new project without using any custom template, the CLI tool will scaffold the counter + powercalculator example. This is an extension to the default Forge counter example when using forge init, adding blended execution.
2. Project Structure
As in Foundry projects, the default source for Foundry to fetch your contracts is the src folder (unless otherwise specified in foundry.toml). Organise your contracts like so:
my-project/
├── src/
│ ├── BlendedCounter.sol # Solidity contract
│ └── power-calculator/ # Rust/WASM module
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
├── test/ # Forge tests
├── script/ # Deployment scripts
└── foundry.toml # Configuration
When you're working on bigger projects with a large set of contracts, it is recommended to add more structure to your code base by using folders and nested structures to group related contracts. When building your contracts (refer to below in step 3), gblend will recursively look for contract source code within the src directory.
3. Build Contracts
Build all contracts (Solidity + Rust WASM)
Note: the first build might take a few minutes and should take a few seconds after the first run.
gblend build
Note: First build may take longer as Docker downloads the container image.
The build command will create build artifacts in the /out directory or otherwise specified in foundry.toml.
These build artificats can be neatly removed from the project by running the clean command:
# Clean build artifacts
gblend clean
4. Run Tests
# Run all tests
gblend test
# Run specific test with gas reporting
gblend test --match-test testIncrementByPowerOfTwo --gas-report
Configuration
foundry.toml
gblend uses the same configuration foundations as Foundry forge. Create (it should already be there if you used gblend or regular forge to create your project) or update a foundry.toml file in your project root:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 200
[rpc_endpoints]
fluent_testnet = "https://rpc.testnet.fluent.xyz"