YouTube Tutorial: Get Started with Foundry
Watch a step-by-step tutorial on how to get started with Foundry.
1. Install the foundry-zksync fork
This installation overrides any existing forge and cast binaries in
~/.foundry
. To revert to the standard foundry installation, follow the
Foundry installation
guide.
You can swap between the two installations at any time.1
Install foundry-zksync
Install the Run You may need to restart your terminal session after installation to continue.
foundryup-zksync
fork:foundryup-zksync
to install forge
, cast
, and anvil
:Common installation issues
Common installation issues
foundryup-zksync: command not found
foundryup-zksync: command not found
Restart your terminal session.
Could not detect shell
Could not detect shell
To add the Replace
foundry
binary to your PATH, run the following command:<your-username-here>
with the correct path to your home directory.Library not loaded: libusb
Library not loaded: libusb
The libusb library may need to be installed manually on macOS.
Run the following command to install the library:
2
Verify installation
A helpful command to check if the installation was successful is:If installed successfully, 20 lines of
--zksync
options will be displayed.2. Create a new project
Create a new project withforge
and change directory into the project.
3. Modify Foundry configuration
Update yourfoundry.toml
file to include the following options:
To use system contracts,
set the
enable_eravm_extensions
flag in [profile.default.zksync]
to true.4. Write a smart contract
Modify thesrc/Counter.sol
file to include the following smart contract:
5. Compile the smart contract
Use the zksolc compiler (installed in the above steps) to compile smart contracts for Abstract:zkout
directory.
6. Deploy the smart contract
Add your private key
Create a new wallet keystore.Enter your wallet’s private key when prompted and provide a password to encrypt it.
We recommend not to use a private key associated with real funds. Create a new wallet for this step.
2
3
Get an Abscan API key (Mainnet only)
Follow the Abscan documentation to get an API key to verify your smart contracts on the block explorer.
This is recommended; but not required.
Deploy your smart contract
Run the following command to deploy your smart contracts:Note: Replace the contract path, address, and Abscan API key with your own.If successful, the output should look similar to the below output, and you can view your contract on a block explorer.