This example demonstrates how to build, test, and deploy a blended Solidity + Rust (WASM) smart contract using Gblend — a Foundry-compatible CLI for the Fluent network.
src/
├── BlendedCounter.sol # Main Solidity contract
└── power-calculator/ # Rust WASM module for power calculations
test/ # Solidity tests
script/ # Deployment scripts
foundry.toml # Project configuration
How it works:
- The Solidity contract
BlendedCounter.solinteracts with a Rust module compiled to WASM. - The Rust module (
power-calculator/) implements computation logic using fluentbase-sdk. - Gblend builds, tests, and deploys both Solidity and Rust components in a single unified workflow.
Create a new blended project:
gblend init my-blended-app
cd my-blended-appTo enable Rust Analyzer and Solidity support, create .vscode/settings.json:
{
"rust-analyzer.linkedProjects": [
"src/power-calculator/Cargo.toml"
],
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"files.watcherExclude": {
"**/target/**": true,
"**/out/**": true
},
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.packageDefaultDependenciesContractsDirectory": ""
}Make sure you have the wasm32 target installed:
rustup target add wasm32-unknown-unknowngblend buildCompiles both Solidity and Rust (WASM) contracts and generates artifacts in the out/ directory.
The first build may take longer as the Fluent build image is downloaded for reproducible builds.
gblend test -vRuns all tests in a shared Fluent-compatible runtime. Both Solidity and Rust contracts execute in the same environment — identical to the runtime used by Fluent nodes on-chain.
Use the provided Forge-style script to deploy both contracts:
gblend script script/Deploy.s.sol \
--private-key $PK \
--rpc-url https://rpc.devnet.fluent.xyz \
--broadcastThis script:
- Deploys the Rust PowerCalculator (compiled to WASM)
- Deploys the Solidity BlendedCounter
- Links them together on-chain
Contracts can be verified separately on Blockscout.
gblend verify-contract <POWER_CALCULATOR_ADDRESS> power-calculator.wasm \
--rpc-url https://rpc.devnet.fluent.xyz \
--wasm \
--verifier blockscout \
--verifier-url https://devnet.fluentscan.xyz/api/gblend verify-contract <BLENDED_COUNTER_ADDRESS> BlendedCounter \
--rpc-url https://rpc.devnet.fluent.xyz \
--verifier blockscout \
--verifier-url https://devnet.fluentscan.xyz/api/Verification for WASM contracts may take several minutes.
You can also deploy a single compiled WASM contract directly:
gblend create power-calculator.wasm \
--rpc-url https://rpc.devnet.fluent.xyz \
--private-key $PK \
--broadcast \
--verify \
--wasm \
--verifier blockscout \
--verifier-url https://devnet.fluentscan.xyz/api/