Skip to content

Commit 0269510

Browse files
Merge pull request #34 from john-walter-munene/feat/Article-deploying-smart-contracts-using-foundry
On adding a guide to deploying smart contracts using foundry.
2 parents 194e35c + 056453c commit 0269510

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: "Deploying Smart Contracts on Mordor and Ethereum Classic Using Foundry"
3+
author: "Kanishk Sogani"
4+
date: "2025-03-17"
5+
image: "/images/deploying-smart-contracts-using-foundry.webp"
6+
excerpt: "Guide: deploying smart contracts on Mordor and Ethereum Classic using Foundry."
7+
---
8+
9+
# Deploying Smart Contracts on Mordor and Ethereum Classic Using Foundry
10+
11+
Ethereum Classic is the original EVM-compatible blockchain and its community of miners, developers and users remain committed to the original principles of blockchains, which include immutability, unstoppability and permissionlessness. These characteristics make Ethereum Classic a great option if you are seeking a stable, mature and time-tested blockchain for your project.
12+
13+
If you want to deploy smart contracts on Mordor or Ethereum Classic using Foundry, there are specific configurations you need to apply to ensure a smooth deployment. This guide walks you through the necessary steps to deploy your contract successfully on both Mordor (testnet) and Ethereum Classic (mainnet).
14+
15+
## Prerequisites
16+
17+
Before proceeding, ensure you have:
18+
19+
- Foundry installed on your system
20+
- A smart contract ready for deployment
21+
- A deployment script (use your own or the example provided below)
22+
- A wallet with test ETC for Mordor or real ETC for Ethereum Classic
23+
24+
If you’re using a different framework (such as Hardhat or Truffle), be sure to check for specific deployment considerations, as newer versions might cause compatibility issues.
25+
26+
## Getting Test ETC for Mordor
27+
28+
To deploy smart contracts on Mordor, you will need test ETC (Ethereum Classic’s testnet currency).
29+
30+
How to get test ETC?
31+
You can obtain test ETC from Mordor faucets. Simply search online for “Mordor testnet faucet” to find available sources that distribute test ETC.
32+
33+
Make sure you use a reputable faucet and verify the network settings before requesting test ETC.
34+
35+
Once you have received test ETC, you can proceed with deployment.
36+
37+
## Configuring Foundry for Mordor & Ethereum Classic
38+
39+
By default, Foundry uses evm_version = “cancun”, which includes post-merge opcodes (such as TSTORE and TLOAD). However, Mordor and Ethereum Classic operate on pre-merge EVM versions (likely Byzantium or Istanbul). Using an unsupported EVM version can result in transaction failures with status: 0 errors.
40+
41+
To avoid this, update your Foundry configuration file:
42+
43+
## Update foundry.toml
44+
Modify your foundry.toml file to set evm_version to “paris”:
45+
46+
```
47+
[profile.default]
48+
src = “src”
49+
out = “out”
50+
libs = [“lib”]
51+
evm_version = “paris” # Ensures compatibility with Mordor & Ethereum Classic
52+
```
53+
54+
After updating, verify the EVM version by running:
55+
56+
```
57+
forge config
58+
```
59+
60+
Ensure the output displays evm_version = “paris”.
61+
62+
## Setting Up Mordor & Ethereum Classic RPC
63+
64+
Mordor is a testnet for Ethereum Classic, while Ethereum Classic itself is the mainnet. To connect Foundry to either network, add the respective RPC URLs to your .env file:
65+
66+
```
67+
MORDOR_RPC_URL=https://rpc.mordor.etccooperative.org
68+
ETC_RPC_URL=https://etc.rivet.link
69+
```
70+
71+
## Compiling the Smart Contract
72+
73+
Before deploying, clean and rebuild your project to ensure no residual issues:
74+
75+
```
76+
forge clean
77+
forge build
78+
```
79+
80+
## Deploying the Smart Contract
81+
82+
If you already have a deployment script, you can reuse it. Otherwise, create a Deploy.s.sol script in the script/ directory using the following example:
83+
84+
```
85+
// SPDX-License-Identifier: MIT
86+
pragma solidity ^0.8.20;
87+
import "forge-std/Script.sol";
88+
import "../src/YourContract.sol";
89+
contract DeployContract is Script {
90+
function setUp() public {}
91+
function run() external {
92+
vm.startBroadcast();
93+
94+
// Deploy your contract
95+
YourContract contractInstance = new YourContract();
96+
//Replace with your contract
97+
vm.stopBroadcast();
98+
console.log("Contract deployed at:", address(contractInstance));
99+
}
100+
}
101+
102+
```
103+
104+
Replace **YourContract** with the name of your actual contract file.
105+
106+
### Deploying to Mordor
107+
108+
Run the deployment script with:
109+
110+
```
111+
forge script script/Deploy.s.sol:DeployContract \
112+
--rpc-url $MORDOR_RPC_URL \
113+
--private-key $PRIVATE_KEY \
114+
--broadcast \
115+
--evm_version paris \
116+
--legacy
117+
```
118+
119+
### Deploying to Ethereum Classic
120+
121+
Run the deployment script with:
122+
123+
```
124+
forge script script/Deploy.s.sol:DeployContract \
125+
--rpc-url $ETC_RPC_URL \
126+
--private-key $PRIVATE_KEY \
127+
--broadcast \
128+
--evm_version paris \
129+
--legacy
130+
+ ```
131+
132+
Make sure you have PRIVATE_KEY set in your .env file before running the deployment script.
133+
134+
### Why We Use — legacy
135+
136+
Ethereum Classic and Mordor do not support EIP-1559 transactions. If you attempt to use EIP-1559-based transactions, you may encounter the following error:
137+
138+
Failed to get EIP-1559 fees; unsupported feature: eip1559
139+
140+
To resolve this, we use the — legacy flag, which forces Foundry to use legacy-style transactions instead of EIP-1559. This ensures compatibility with networks that do not support priority fees or dynamic gas pricing.
141+
142+
## Checking Deployment & Adding Networks
143+
144+
You can verify your contract deployment and add the respective networks to your wallet using the following links:
145+
146+
### Block Explorers to check deployment:
147+
148+
- [Mordor Explorer](https://etc-mordor.blockscout.com/)
149+
- [Ethereum Classic Explorer](https://etc.blockscout.com/)
150+
151+
### Chainlist to Add Networks:
152+
- [Chainlist to Add Networks:](https://chainlist.org/?search=mordor&testnets=true)
153+
- [Add Ethereum Classic to Wallet](https://chainlist.org/?search=etc)
154+
155+
## Conclusion
156+
157+
By following these steps, you can successfully deploy smart contracts on both Mordor and Ethereum Classic using Foundry. Ensuring the correct EVM version and handling legacy transactions appropriately will help prevent common deployment issues.
33.4 KB
Loading

0 commit comments

Comments
 (0)