Skip to content

Commit

Permalink
Config and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
icyfry committed Apr 8, 2024
1 parent 1dc2d43 commit ea86588
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
10 changes: 6 additions & 4 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# 0x....
PUBLIC_KEY_LOCAL=
# Anvil
RPC_URL=http://127.0.0.1:8545
PUBLIC_KEY=
RPC_URL=
ETHERSCAN_API_KEY=
# Contracts
FUNDME_ADDRESS=
CRYPTOZOMBIES_ADDRESS=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Dotenv file
.env
.env.local
.env.mainnet
.env.sepolia
.password
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ Test call with cast for Cryptozombies
cast call 0x... "getZombiesByOwner(address _owner)" "0x..."
```

### Gas

Create a gas usage snapshot file `.gas-snapshot` with `forge snapshot`

## Run Contracts and Frontend

Launch a local testnet node, see [Anvil doc](https://book.getfoundry.sh/reference/anvil/)
```
anvil
```
Build and deploy contracts on local testnet
Build and deploy contracts
```
task contracts-build contracts-deploy-script
or
task contracts-build contracts-deploy
```
Launch frontend
```
Expand Down
41 changes: 37 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: '3'

dotenv: ['.env']
env:
ENV: local

dotenv: ['.env', '.env.{{.ENV}}']

tasks:

Expand All @@ -19,15 +22,26 @@ tasks:
cmds:
- forge test -vvv --gas-report

contracts-gas:
dir: contracts
cmds:
- forge snapshot

contracts-deploy-script:
dir: contracts/script
cmds:
- forge script --rpc-url {{.RPC_URL}}
--account defaultKey
--sender {{.PUBLIC_KEY_LOCAL}}
--sender {{.PUBLIC_KEY}}
--broadcast
--password-file "../.password"
DeployZombieOwnership
- forge script --rpc-url {{.RPC_URL}}
--account defaultKey
--sender {{.PUBLIC_KEY}}
--broadcast
--password-file "../.password"
DeployFundMe

contracts-deploy:
dir: contracts
Expand All @@ -36,8 +50,27 @@ tasks:
--account defaultKey
--password-file ".password"
src/cryptozombies/zombieownership.sol:ZombieOwnership
# --interactive
# --private-key {{.PRIVATE_KEY_LOCAL}}

fundme-FundFundMe:
dir: contracts/script
cmds:
- forge script --rpc-url {{.RPC_URL}}
--account defaultKey
--sender {{.PUBLIC_KEY}}
--broadcast
--password-file "../.password"
InteractionsFundMe.s.sol:FundFundMe

fundme-WithdrawFundMe:
dir: contracts/script
cmds:
- forge script --rpc-url {{.RPC_URL}}
--account defaultKey
--sender {{.PUBLIC_KEY}}
--broadcast
--password-file "../.password"
InteractionsFundMe.s.sol:WithdrawFundMe

frontend-build:
dir: dapp
cmds:
Expand Down
1 change: 1 addition & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cache/
out/
bin/
broadcast/
.gas-snapshot

# Ignores development broadcast logs
!/broadcast
Expand Down
7 changes: 7 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ libs = ["lib"]
solc = "0.8.20"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }

[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"

0 comments on commit ea86588

Please sign in to comment.