Deploying with Foundry on Cuckoo Chain
This tutorial will guide you through deploying an ERC20 token on Cuckoo Chain using Foundry. Foundry is a Rust-based smart contract development toolchain that manages dependencies, compiles projects, runs tests, deploys, and allows interaction with the chain via command-line and Solidity scripts.
Given Cuckoo Chain's foundation on the Arbitrum and Ethereum Stack and its EVM compatibility, Ethereum-based smart contracts can be ported easily with minimal adjustments.
Prerequisites
You need to complete the following steps, which should take around 10 minutes:
-
Get $CAI on Cuckoo Testnet Network: Use this faucet to claim some CAI.
-
Install Rust: If Rust is not installed, follow this guide.
-
Install Foundry: If Foundry is not installed, follow this guide.
Let's get started!
Step 1: Setting Up the Project
1.1 Initialize a New Foundry Project
Open a terminal and run:
forge init my-project
1.2 Install OpenZeppelin Contracts
Add the OpenZeppelin contracts library to your project:
forge install OpenZeppelin/openzeppelin-contracts
Step 2: Writing the ERC20 Token Contract
2.1 Create the Contract File
In the /src
directory, create a file named MyERC20.sol
and add the following code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
contract MyERC20 is ERC20 {
constructor() ERC20("MyToken", "MTK") {}
}
This simple ERC20 token is named "MyToken" with the symbol "MTK". You can modify the name and symbol as desired.
Here's what your project should look like so far:
Step 3: Building the Contract
3.1 Compile the Smart Contract
Use Foundry to compile your contract:
forge build