Using Foundry
This page describes how to deploy smart contracts using Foundry.
Last updated
Was this helpful?
This page describes how to deploy smart contracts using Foundry.
Last updated
Was this helpful?
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 and via Solidity scripts.
Foundry book, see:
and .
Create a project with Foundry, forge init
and cd
into it:
Let's check out what forge
generated for us:
We Can build the project with forge build
:
And run the tests with forge test
:
Deploy the contract from your project, located at src/Counter.sol
. Replace YOUR_PRIVATE_KEY
with your private key, mentioned in the previous prerequisites section.
--legacy
flag means Use legacy transactions instead of EIP1559 ones. This is auto-enabled for common networks without EIP1559.
<unlock_time>
is the Unix timestamp after which the funds locked in the contract will become available for withdrawal. Try setting this to some Unix timestamp in the future, like 1696118400
(this Unix timestamp corresponds to October 1, 2023).
<lock_amount>
is the amount of test ETH
to be locked in the contract. Try setting this to some small amount, like 0.0000001ether
.
For information on additional flag options, follow this