Building a Blended App
Introduction
This guide provides detailed instructions on how to build a blended HelloWorld application on Fluent. It combines a Rust smart contract to print “Hello” and a Solidity smart contract to print “World.”
This setup demonstrates:
composability between different programming languages (Solidity and Rust)
and interoperability between different virtual machine targets (EVM and Wasm)
within a single execution environment.
Prerequisites
Ensure you have the following installed:
Node.js and npm
Rust and Cargo
Hardhat
pnpm (install via npm:
npm install -g pnpm)
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:
Step 1: Initialize Your Rust Project
1.1 Set Up the Rust Project
1.2 Configure the Rust Project
Cargo.toml
1.3 Write the Rust Smart Contract
src/lib.rs
1.4 Build the Wasm Project
Run:
Step 2: Initialize Your Solidity Project
2.1 Create Your Project Directory
2.2 Install Dependencies
2.3 Configure TypeScript and Hardhat
2.3.1 Update Hardhat Configuration
hardhat.config.ts
2.3.2 Update package.json
package.json
2.4 Set Up Environment Variables
Create a .env file:
Replace
your-private-key-herewith your actual private key.
2.5 Write the Solidity Contracts
Create a
contractsdirectory and add the following:
2.5.1 Define the Interface
contracts/IFluentGreeting.sol
2.5.2 Implement the Greeting Contract
contracts/GreetingWithWorld.sol
Step 3: Deploy Both Contracts Using Hardhat
3.1 Create the Deployment Script
This deployment script is responsible for deploying both the Rust smart contract (compiled to Wasm) and the Solidity smart contract (GreetingWithWorld).
deploy/01_deploy_contracts.ts
3.2 Create the Hardhat Task
tasks/get-greeting.ts
3.3 Compile and Deploy the Contracts
Run the following commands to compile and deploy your contracts:
Last updated