forked from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4240e17
commit 9091bfc
Showing
12 changed files
with
394 additions
and
243 deletions.
There are no files selected for viewing
24 changes: 21 additions & 3 deletions
24
templates/solidity-frameworks/foundry/packages/foundry/.env.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
DEPLOYER_PRIVATE_KEY= | ||
ETHERSCAN_API_KEY= | ||
ALCHEMY_API_KEY= | ||
# Template for foundry environment variables. | ||
|
||
# For local development, copy this file, rename it to .env, and fill in the values. | ||
|
||
# We provide default values so developers can start prototyping out of the box, | ||
# but we recommend getting your own API Keys for Production Apps. | ||
|
||
# DEPLOYER_PRIVATE_KEY is used while deploying contract. | ||
# On anvil chain the value of it can be empty since we use the prefunded account | ||
# which comes with anvil chain to deploy contract. | ||
# NOTE: You don't need to manually change the value of DEPLOYER_PRIVATE_KEY, it should | ||
# be auto filled when run `yarn generate`. | ||
# Although `.env` is ignored by git, it's still important that you don't paste your | ||
# actual account private key and use the generated one. | ||
# Alchemy rpc URL is used while deploying the contracts to some testnets/mainnets, checkout `foundry.toml` for it's use. | ||
ALCHEMY_API_KEY=oKxs-03sij-U_N0iOlrSsZFr29-IqbuF | ||
|
||
# Etherscan API key is used to verify the contract on etherscan. | ||
ETHERSCAN_API_KEY=DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW | ||
# Default account for localhost / use "scaffold-eth-custom" if you wish to use a generated account or imported account | ||
ETH_KEYSTORE_ACCOUNT=scaffold-eth-default |
23 changes: 20 additions & 3 deletions
23
templates/solidity-frameworks/foundry/packages/foundry/.env.template.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
const contents = () => | ||
`DEPLOYER_PRIVATE_KEY= | ||
`# Template for foundry environment variables. | ||
# For local development, copy this file, rename it to .env, and fill in the values. | ||
# We provide default values so developers can start prototyping out of the box, | ||
# but we recommend getting your own API Keys for Production Apps. | ||
# DEPLOYER_PRIVATE_KEY is used while deploying contract. | ||
# On anvil chain the value of it can be empty since we use the prefunded account | ||
# which comes with anvil chain to deploy contract. | ||
# NOTE: You don't need to manually change the value of DEPLOYER_PRIVATE_KEY, it should | ||
# be auto filled when run \`yarn generate\`. | ||
# Although \`.env\` is ignored by git, it's still important that you don't paste your | ||
# actual account private key and use the generated one. | ||
# Alchemy rpc URL is used while deploying the contracts to some testnets/mainnets, checkout \`foundry.toml\` for it's use. | ||
ALCHEMY_API_KEY=oKxs-03sij-U_N0iOlrSsZFr29-IqbuF | ||
# Etherscan API key is used to verify the contract on etherscan. | ||
ETHERSCAN_API_KEY=DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW | ||
` | ||
# Default account for localhost / use "scaffold-eth-custom" if you wish to use a generated account or imported account | ||
ETH_KEYSTORE_ACCOUNT=scaffold-eth-default`; | ||
|
||
export default contents | ||
export default contents; |
89 changes: 89 additions & 0 deletions
89
templates/solidity-frameworks/foundry/packages/foundry/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
.PHONY: build deploy generate-abis verify-keystore account chain compile deploy-verify flatten fork format lint test verify | ||
|
||
# setup wallet for anvil | ||
setup-anvil-wallet: | ||
shx rm ~/.foundry/keystores/scaffold-eth-default 2>/dev/null; \ | ||
cast wallet import --private-key 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 --unsafe-password 'localhost' scaffold-eth-default | ||
|
||
# Start local chain | ||
chain: setup-anvil-wallet | ||
anvil | ||
|
||
# Start a fork | ||
fork: setup-anvil-wallet | ||
anvil --fork-url ${FORK_URL} --chain-id 31337 | ||
|
||
# Build the project | ||
build: | ||
forge build --build-info --build-info-path out/build-info/ | ||
|
||
# Deploy the project | ||
deploy: | ||
@if [ "$(RPC_URL)" = "localhost" ]; then \ | ||
forge script script/Deploy.s.sol --rpc-url localhost --password localhost --broadcast --legacy --ffi; \ | ||
else \ | ||
forge script script/Deploy.s.sol --rpc-url $(RPC_URL) --broadcast --legacy --ffi; \ | ||
fi | ||
|
||
# Build and deploy target | ||
build-and-deploy: build deploy generate-abis | ||
|
||
# Generate TypeScript ABIs | ||
generate-abis: | ||
node scripts-js/generateTsAbis.js | ||
|
||
verify-keystore: | ||
if grep -q "scaffold-eth-default" .env; then \ | ||
cast wallet address --password localhost; \ | ||
else \ | ||
cast wallet address; \ | ||
fi | ||
|
||
# List account | ||
account: | ||
@node scripts-js/ListAccount.js $$(make verify-keystore) | ||
|
||
# Generate a new account | ||
account-generate: | ||
@cast wallet import $(ACCOUNT_NAME) --private-key $$(cast wallet new | grep 'Private key:' | awk '{print $$3}') | ||
@echo "Please update .env file with ETH_KEYSTORE_ACCOUNT=$(ACCOUNT_NAME)" | ||
|
||
# Import an existing account | ||
account-import: | ||
@cast wallet import ${ACCOUNT_NAME} --interactive | ||
|
||
# Compile contracts | ||
compile: | ||
forge compile | ||
|
||
# Deploy and verify | ||
deploy-verify: | ||
@if [ "$(RPC_URL)" = "localhost" ]; then \ | ||
forge script script/Deploy.s.sol --rpc-url localhost --password localhost --broadcast --legacy --ffi --verify; \ | ||
else \ | ||
forge script script/Deploy.s.sol --rpc-url $(RPC_URL) --broadcast --legacy --ffi --verify; \ | ||
fi | ||
node scripts-js/generateTsAbis.js | ||
|
||
# Flatten contracts | ||
flatten: | ||
forge flatten | ||
|
||
# Format code | ||
format: | ||
forge fmt && prettier --write ./scripts-js/**/*.js | ||
|
||
# Lint code | ||
lint: | ||
forge fmt --check && prettier --check ./script/**/*.js | ||
|
||
# Run tests | ||
test: | ||
forge test | ||
|
||
# Verify contracts | ||
verify: | ||
forge script script/VerifyAll.s.sol --ffi --rpc-url $(RPC_URL) | ||
|
||
build-and-verify: build verify | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
templates/solidity-frameworks/foundry/packages/foundry/script/DeployYourContract.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "../contracts/YourContract.sol"; | ||
import "./DeployHelpers.s.sol"; | ||
|
||
contract DeployYourContract is ScaffoldETHDeploy { | ||
// use `deployer` from `ScaffoldETHDeploy` | ||
function run() external ScaffoldEthDeployerRunner { | ||
YourContract yourContract = new YourContract(deployer); | ||
console.logString(string.concat("YourContract deployed at: ", vm.toString(address(yourContract)))); | ||
} | ||
} |
Oops, something went wrong.