Foundry I
Foundry is a smart contract development toolchain.
Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line.
Foundry Resources
The Foundry Book is the definitive resource if you want to read more about Foundry. How to Foundry is an excellent introductory video.
Installation
Open your terminal and type in the following command:
curl -L https://foundry.paradigm.xyz | bash
This will download foundryup
. Then install Foundry by running:
foundryup
To verify that Foundry is installed, run forge --version
:
forge - -version
You see the following message.
forge 0.2.0 (91b1292 2024–06–09T00:20:11.408407000Z)
forge init
To start a new project with Foundry, use forge init
:
Note=If it doesn’t work, you can use forge init — force
forge init hello_foundry2
cd hello_foundry2
This is representation of “hello_foundry2” in your home root.
There are 3 directories.
forge build
We can build the project with forge build
:
forge build
You see the following message.
forge test
And run the tests with forge test
:
forge test
You see the following message.
Ok.
We tested the Counter.t.sol file in test/Counter.t.sol.
Two tests passed.
Fucking openzeppelin and foundry physical path problem
Do you want to install openzeppelin ?
forge install openzeppelin/openzeppelin-contracts
didnt work ?
forge install OpenZeppelin/openzeppelin-contracts — no-commit
and system load this repository to the lib folder
but you need to arrange for using NPM style physical path
touch remappings.txt
add the following path to the .txt file
openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/
save it !
You can now import openzeppelin files as
import “openzeppelin-contracts/security/ReentrancyGuard.sol”;
import “openzeppelin-contracts/access/Ownable.sol”;
Please follow my articles on Foundry…