Skip to main content

Foundry - Smart Contracts

Foundry’s installation and setup is simple and straightforward. We will need to configure our Foundry project for the MANTRA Chain Dukong testnet but, we’ll get to that later.

Next.js + Rainbowkit - Frontend

For this guide we’ve chosen to use Rainbowkit in building the frontend. Rainbowkit gives us out-of-the-box wallet management for our dapp. Aside from handling the connection and disconnection of wallets, RainbowKit supports numerous wallets, swaps connection chains, resolves address to ENS, displays balance and much more! Rainbowkit is a React library and, as such, needs Node.js to be installed. In building the dApp for this guide the current stable version (v24.11) was used. To make it easy to install and switch between Node versions, the Node Version Manager (NVM) is a very helpful tool.

Foundry Configuration

In the contracts directory of the RealEstateToken sample project you’ll find the Foundry project. There is not much configuration required to get ready for building and deploying the Solidity contracts. This configuration is already present in the sample project. First, create a .env file in the contracts directory with the following content:
DUKONG_RPC_URL=https://evm.dukong.mantrachain.io
and then in a terminal source the .env file to make the DUKONG_RPC_URL environment variable available. This step is merely a convenience used in command to deploy the contracts. It’s not strictly necessary. Next, open the foundry.toml file in your favourite editor. We need to add just a single line here that allows us to deploy our contracts with a Foundry script. You only need to add the following:
[profile.5887]
just after the default Foundry configuration. Your foundry.toml file should look like this:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

[profile.5887]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
This small addition will allow us to refer to the Dukong testnet by its chain ID when deploying the compiled contracts.