This is part of the Cyfrin Updraft Solidity Blockchain Course.
⭐️ Updraft | Foundry Simple Storage
🎥 YouTube (6:23:59) | Section 6 | Foundry Simple Storage
git --version
and you see a response like git version x.x.x
forge --version
and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
anvil --version
and see a response like anvil 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
If you can't or don't want to run and install locally, you can work with this repo in Gitpod. If you do this, you can skip the clone this repo
part.
Clone this repo
git clone https://github.com/Cyfrin/foundry-simple-storage-cu
cd foundry-simple-storage-cu
anvil
chain by running the following in your terminal:anvil
You'll get a large output where the ending looks something like:
==================
31337
Base Fee
==================
1000000000
Gas Limit
==================
30000000
Genesis Timestamp
==================
1717267365
Listening on 127.0.0.1:8545
Listening on XXX
and place it into your .env
file similar to what's in .env.example
, and add an http://
to it..env
Example:
RPC_URL=http://127.0.0.1:8545
Private Keys
==================
(0) 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
(1) 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
(2) 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
(3) 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
(4) 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
(5) 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
(6) 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
(7) 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356
(8) 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
(9) 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
Wallet
==================
Mnemonic: test test test test test test test test test test test junk
Derivation path: m/44'/60'/0'/0/
Grab the top key and place it into your .env
.
.env
Example:
PRIVATE_KEY=11ee3108a03081fe260ecdc106554d09d9d1209bcafd46942b10e02943effc4a
Run
forge compile
forge create SimpleStorage --private-key <PRIVATE_KEY>
Make sure you have a metamask or other wallet, and export the private key.
IMPORTANT
USE A METAMASK THAT DOESNT HAVE ANY REAL FUNDS IN IT. Just in case you accidentally push your private key to a public place. I highly recommend you use a different metamask or wallet when developing.
.env
file. DO NOT USE A KEY ASSOCIATED WITH REAL FUNDS. If you plan to, follow the instructions laid out in this section:
.env
file.forge create SimpleStorage --private-key <PRIVATE_KEY> --rpc-url <ALCHEMY_URL>
Or, you can use a deploy script!
forge script script/DeploySimpleStorage.s.sol --private-key <PRIVATE_KEY> --rpc-url <ALCHEMY_URL>
forge --version
and you see a response like forge 0.0.2 (816e00b 2023-03-16T00:05:26.396218Z)
0.0.2
, and for vanilla it is 0.2.0
(these are versions which may change over time).docker --version
and you see a response like Docker version 20.10.7, build f0df350
node --version
and you see a response like v14.17.0
npm --version
and you see a response like 6.14.13
npx zksync-cli dev config
Select in-memory node
and no additional plugins.
npx zksync-cli dev start
If you get an error like: Command exited with code 1: Error response from daemon: dial unix docker.raw.sock: connect: connection refused
, this means docker is not running.
forge create src/SimpleStorage.sol:SimpleStorage --rpc-url http://127.0.0.1:8011 --private-key xxx --legacy --zksync
or
forge script script/DeploySimpleStorage.s.sol --private-key xxx --rpc-url http://127.0.0.1:8011 --legacy --zksync --broadcast
If you appreciated this, feel free to follow me or donate!
ETH/zkSync/Arbitrum/Optimism/etc Address: cyfrin1.eth
: 0x3846c3A30E62075Fa916216b35EF04B8F53931f6 (Confirm the ENS matches the address!)