Install Foundry
curl -L https://foundry.paradigm.xyz | bash
Warning: Depending on your OS, you might encounter one of these two warnings:
macOS: Warning: libusb not found. You may need to install it manually on macOS via Homebrew (brew install libusb). Detected your preferred shell is zsh and added foundryup to PATH. Run 'source /Users/sanghamitrabhowmick/.zshenv' or start a new terminal session to use foundryup. Then, simply run 'foundryup' to install Foundry.
Solution:
brew install libusb
source /Users/USERNAME/.zshenv
foundryup
Debian/bash: Detected your preferred shell is bash and added foundryup to PATH. Run 'source /home/ubuntu/.bashrc' or start a new terminal session to use foundryup. Then, simply run 'foundryup' to install Foundry.
Solution:
source /home/USERNAME/.bashrc
Setting up the project folder
mkdir foundry
cd foundry
foundryup
forge init vehilce-nft --no-git (or setting up git account)
cd vehicle-nft
delete src/Counter.sol, test/Counter.t.sol, script/Counter.s.sol
Install the OpenZeppelin-Dependencies
cd lib/
git clone https://github.com/OpenZeppelin/openzeppelin-contracts
Create the contracts file: src/VehicleNFT.sol, the test file: test/VehicleNFT.t.sol, the deployment script: script/Vehicle.s.sol, and the interaction script: script/InteractVehicleNFT.s.sol.
Clone the Repository
git clone -b master https://github.com/FTI1DS/vehicle-NFT.git
cd vehicle-NFT
Install Foundry on the machine
To install Foundry correctly, follow step 1 of 'Steps to create the Project from zero'
forge build
forge test
Important: Enter your private key into the .env file like this example. It's important to add 0x before the key. Example: PRIVATE_KEY=0x5323614sdkjbrrkjq3...
Deploy the contract: forge script script/VehicleNFT.s.sol --rpc-url https://geneva-rpc.moonchain.com --broadcast
create a flattened contract file for verifing: forge flatten src/VehicleNFT.sol > flattened_VehicleNFT.sol
verify the contract:
- open contract on geneva explorer, click on contract > Verify & publish
- choose 0.8.26 compiler, evm:istanbul, copy the flattened_VehicleNFT.sol-Code into the textfield and click on Verify
- Change Contract-address in script/InteractVehicleNFT.s.sol
forge script script/InteractVehicleNFT.s.sol --rpc-url https://geneva-rpc.moonchain.com --private-key <PRIVATE_KEY> --broadcast
- Change Contract-address in script/InteractVehicleNFT.s.sol
- forge script script/InteractVehicleNFT.s.sol --rpc-url https://geneva-rpc.moonchain.com --private-key <PRIVATE_KEY> --broadcast