Skip to content

Commit

Permalink
chore: add mainnet and opt fork urls to .env.example (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaopengjun5162 authored Feb 21, 2025
1 parent 7dfb4c3 commit de4a4b8
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
SEPOLIA_RPC_URL=
ETHERSCAN_API_KEY=
PRIVATE_KEY=
ACCOUNT_ADDRESS=
MAINNET_FORK_URL=
OPT_FORK_URL=
SEPOLIA_RPC_URL=<YOUR_ETHERSCAN_API_KEY>
DEV_PRIVATE_KEY=0x123
ETHERSCAN_API_KEY=<YOUR_ETHERSCAN_API_KEY>
CHAIN_ID=11155111
58 changes: 58 additions & 0 deletions script/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# effect the env vars
source .env

# get bash arg
while [[ "$#" -gt 0 ]]; do
case $1 in
--file) SCRIPT_FILE="$2"; shift ;;
--account) ACCOUNT="$2"; shift ;;
*) echo "unknown arg: $1" ; exit 1 ;;
esac
shift
done

# make sure the script file was provided
if [[ -z "$SCRIPT_FILE" ]]; then
echo "Please specify --file <your_script_path>"
exit 1
fi

if [[ -z "$ACCOUNT" ]]; then
echo "Please specify --account <your_cast_wallet_account>"
exit 1
fi

# check if the environment variables were defined previously
if [[ -z "$SEPOLIA_RPC_URL" || -z "$ETHERSCAN_API_KEY" || -z "$CHAIN_ID" ]]; then
echo "Please ensure .env defines the vars:SEPOLIA_RPC_URL, ETHERSCAN_API_KEY, CHAIN_ID"
exit 1
fi

if [[ -z "$PRIVATE_KEY" ]]; then
echo "Can not load the private key from keystore..."
exit 1
fi

# deploy
forge script "$SCRIPT_FILE" \
--rpc-url "$SEPOLIA_RPC_URL" \
--broadcast \
--verify \
--etherscan-api-key "$ETHERSCAN_API_KEY" \
--account $ACCOUNT \
-vvvv

# 导入钱包私钥到-keystore
# cast wallet import Metamask -i
# cast wallet list
# cat ~/.foundry/keystores/Metamask

# 使用编写好的bash脚本

# --file 参数指定要部署的文件 例如 -file script/DeployMyToken.s.sol:DeployMyToken
# --account 参数指定你用cast wallet import 的 account
# 在部署的过程中会问询你输入创建account时的密码

# bash ./script/deploy.sh --file script/DeployMyToken.s.sol:DeployMyToken --account Metamask
29 changes: 29 additions & 0 deletions slither.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"detectors_to_exclude": [
"assembly",
"solc-version",
"naming-convention",
"incorrect-equality",
"uninitialized-local",
"timestamp",
"low-level-calls",
"unimplemented-functions",
"too-many-digits",
"similar-names",
"calls-loop",
"arbitrary-send-eth",
"reentrancy-no-eth",
"reentrancy-benign",
"reentrancy-events",
"unused-state"
],
"filter_paths": ["lib/", "test/", "mocks/", "BytesLib/", "script/"],
"solc_remaps": [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/"
],
"solc_version": "0.8.20",
"exclude_test_files": true,
"exclude_mock_files": true
}

0 comments on commit de4a4b8

Please sign in to comment.