-
-
Notifications
You must be signed in to change notification settings - Fork 185
Migrate smart contract development environment from Hardhat to Foundry #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Basharkhan7776
wants to merge
3
commits into
AOSSIE-Org:main
Choose a base branch
from
Basharkhan7776:issue-#149
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
cc19f2a
chore: Migrate blockchain development from Hardhat to Foundry and int…
Basharkhan7776 e6542b1
feat: Migrate blockchain dependency management to npm and update Chai…
Basharkhan7776 851468d
feat: Add Bun lockfile for client dependencies and update ElectionFac…
Basharkhan7776 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| node_modules | ||
| .env | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
| /artifacts | ||
| # Foundry | ||
| out | ||
| cache | ||
| cache_forge | ||
| broadcast | ||
| lib | ||
| artifacts | ||
|
|
||
| # TypeChain files | ||
| /typechain | ||
| /typechain-types | ||
| # Environment | ||
| .env | ||
|
|
||
| # solidity-coverage files | ||
| /coverage | ||
| /coverage.json | ||
| # Dependencies | ||
| node_modules | ||
| forge_std | ||
|
|
||
| # Hardhat Ignition default folder for deployments against a local node | ||
| ignition/deployments/chain-31337 | ||
| # Misc | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,12 @@ | ||
| FROM node:20-slim | ||
| FROM ghcr.io/foundry-rs/foundry:latest | ||
|
|
||
| WORKDIR /app/blockchain | ||
|
|
||
| # Install Python and build dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| python3 \ | ||
| python3-pip \ | ||
| build-essential \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set Python path for node-gyp | ||
| ENV PYTHON=/usr/bin/python3 | ||
|
|
||
| COPY package*.json ./ | ||
| RUN npm install | ||
| WORKDIR /app | ||
|
|
||
| # Copy our source code | ||
| COPY . . | ||
|
|
||
| CMD ["npx", "hardhat", "node"] | ||
| # Build the project | ||
| RUN forge build | ||
|
|
||
| # Set the entrypoint to anvil (local testnet) or forge | ||
| CMD ["anvil", "--host", "0.0.0.0"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,71 @@ | ||
| # Sample Hardhat Project | ||
| # Agora Blockchain Project | ||
|
|
||
| This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract. | ||
| This project contains the smart contracts for Agora Blockchain, built using **Foundry**. | ||
|
|
||
| Try running some of the following tasks: | ||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - [Foundry](https://book.getfoundry.sh/getting-started/installation) | ||
|
|
||
| ### Build | ||
|
|
||
| ```shell | ||
| forge build | ||
| ``` | ||
|
|
||
| ### Test | ||
|
|
||
| ```shell | ||
| forge test | ||
| ``` | ||
|
|
||
| ### Format | ||
|
|
||
| ```shell | ||
| forge fmt | ||
| ``` | ||
|
|
||
| ### Local Node | ||
|
|
||
| Start a local testnet: | ||
|
|
||
| ```shell | ||
| anvil | ||
| ``` | ||
|
|
||
| ### Deploy | ||
|
|
||
| To deploy contracts, use `forge create` or `forge script`. | ||
|
|
||
| ```shell | ||
| npx hardhat help | ||
| npx hardhat test | ||
| REPORT_GAS=true npx hardhat test | ||
| npx hardhat node | ||
| npx hardhat ignition deploy ./ignition/modules/Lock.js | ||
| forge script script/MyScript.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
| ``` | ||
|
|
||
| Live Code at | ||
| ## Live Code | ||
|
|
||
| - Election Factory - https://sepolia.etherscan.io/address/0x64c720eBD5227bba57a5E8282893e71087cCcBb8#code | ||
| - CCIP Sender :- | ||
| - Fuji - https://testnet.snowtrace.io//address/0xf267f0603672E791779E52B153BD9A39C9928767#code | ||
|
|
||
| Gas Comparision : | ||
| ## Gas Comparison (Historical) | ||
|
|
||
| Create Election : | ||
| **Create Election:** | ||
|
|
||
| 0.011334162446332343 - Before | ||
| 0.002298823499424792 - After | ||
| - 0.011334162446332343 - Before | ||
| - 0.002298823499424792 - After | ||
|
|
||
| Add Candidate: | ||
| **Add Candidate:** | ||
|
|
||
| 0.000716409329167840 - Before | ||
| 0.000256279986480672 - After | ||
| - 0.000716409329167840 - Before | ||
| - 0.000256279986480672 - After | ||
|
|
||
| Vote: | ||
| 0.00027771 - Before | ||
| 0.00050715 - After | ||
| **Vote:** | ||
|
|
||
| Before IPFS | ||
| - 0.00027771 - Before | ||
| - 0.00050715 - After | ||
|
|
||
| Medium Description : 0.00197243 SepoliaETH | ||
| Large Description : 0.00537738 SepoliaETH | ||
| **IPFS Optimization:** | ||
|
|
||
| After IPFS | ||
| Medium Description : 0.00035482 SepoliaETH | ||
| Large Description : 0.00035595 SepoliaETH | ||
| - Medium Description: 0.00197243 -> 0.00035482 SepoliaETH | ||
| - Large Description: 0.00537738 -> 0.00035595 SepoliaETH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [profile.default] | ||
| src = "contracts" | ||
| out = "out" | ||
| libs = ["node_modules", "lib"] | ||
| test = "test" | ||
| cache = true | ||
| cache_path = "cache_forge" | ||
| force = false | ||
| evm_version = "paris" | ||
| gas_reports = ["*"] | ||
|
|
||
| [rpc_endpoints] | ||
| sepolia = "${RPC_URL_SEPOLIA}" | ||
| amoy = "${RPC_URL_AMOY}" | ||
|
|
||
| [etherscan] | ||
| sepolia = { key = "${ETHERSCAN_KEY}" } |
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...ition/deployments/chain-11155111/artifacts/ElectionFactoryModule#ElectionFactory.dbg.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.