Solidity
Building in Solidity
Fluent is an EVM-compatible L2 that allows developers to deploy familiar applications written in Solidity. Note however that many of the unique technical value proposition lies in so called blended execution, but nevertheless migration of existing Solidity based code bases is possible on Fluent.
Before getting started, make sure to install either of the following:
gblend
: find the installation instructions here- Foundry: find the installation instructions in the official Foundry docs
If you're starting a new project on Fluent Network, we recommend using gblend
over regular Foundry forge, even if you have no immediate plans of making your application blended by adding Fluentbase Rust contracts. Your application might still interact with another application that is blended which may lead to issues relying on regular forge.
Nevertheless, as the instructions to build Solidity contracts with gblend
can be found in the gblend
usage docs, this guide will use regular forge for demonstration purposes.
Start Foundry Project
Generate Foundry file in your current directory
forge init
In the src
folder, create a new file called SimpleStorage.sol
and copy the simple contract below:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
contract SimpleStorage {
uint256 public storedData; //Do not set 0 manually it wastes gas!
event setEvent();
function set(uint256 x) public {
storedData = x;
emit setEvent();
}
}
Deploy and Verify
- Testnet
- Devnet
forge create SimpleStorage \
--private-key $PRIVATE_KEY \
--rpc-url https://rpc.testnet.fluent.xyz/ \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://testnet.fluentscan.xyz/api/
forge create SimpleStorage \
--private-key $PRIVATE_KEY \
--rpc-url https://rpc.devnet.fluent.xyz/ \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://devnet.fluentscan.xyz/api/
Blockscout verification might fail during deployment. If this happens, verify the contract after it is deployed.
Make sure to capture the contract address from the output of the deployment step above.
Verify Contract Already Deployed
Replace variable <contract_address>
in the commands below with the actual contract address from the deployment step above and run:
- Testnet
- Devnet
forge verify-contract \
--rpc-url https://rpc.testnet.fluent.xyz/ \
<contract_address> \
SimpleStorage \
--verifier blockscout \
--verifier-url https://testnet.fluentscan.xyz/api/
forge verify-contract \
--rpc-url https://rpc.devnet.fluent.xyz/ \
<contract_address> \
SimpleStorage \
--verifier blockscout \
--verifier-url https://devnet.fluentscan.xyz/api/
Even though Fluent Network has an innovative blended execution engine, it is still an EVM-compatible L2. This means that Solidity contracts can be deployed and verified on Fluent Network just like on any other EVM-compatible network using Foundry and other familiar tools.