Skip to content

Commit fbf1bd6

Browse files
committed
Added initial scripts
1 parent b433db3 commit fbf1bd6

File tree

5 files changed

+135
-5
lines changed

5 files changed

+135
-5
lines changed

.env.example

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ETHERSCAN_API_KEY=<YOUR_ETHERSCAN_API_KEY>
2-
SEPOLIA_URL=https://eth-sepolia.g.alchemy.com/v2/<YOUR_ALCHEMY_API_KEY>
3-
MAINNET_URL=https://eth-mainnet.g.alchemy.com/v2/<YOUR_ALCHEMY_API_KEY>
1+
BLOCKSCOUT_APIKEY=<YOUR_BLOCKSCOUT_APIKEY>
42
PRIVATE_KEY=<YOUR_PRIVATE_KEY>
3+
LEDGER_HD_PATH=<m/44'/60'/0'/0/0>

contracts/staking/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ Contract threat models and audits:
3737

3838
**Deploy and verify using CREATE3 factory contract:**
3939

40-
This repo includes a script for deploying via a CREATE3 factory contract. The script is defined as a test contract as per the examples [here](https://book.getfoundry.sh/reference/forge/forge-script#examples) and can be found in `./script/staking/DeployStakeHolder.sol`.
40+
This repo includes a script for deploying via a CREATE3 factory contract. The script is defined as a test contract as per the examples [here](https://book.getfoundry.sh/reference/forge/forge-script#examples) and can be found in `./script/staking/DeployStakeHolder.t.sol`.
4141

4242
See the `.env.example` for required environment variables.
4343

4444
```sh
45-
forge script script/staking/DeployStakeHolder.sol --tc DeployStakeHolder --sig "deploy()" -vvv --rpc-url {rpc-url} --broadcast --verifier-url https://explorer.immutable.com/api --verifier blockscout --verify --gas-price 10000000000
45+
forge script script/staking/DeployStakeHolder.t.sol --tc DeployStakeHolder --sig "deploy()" -vvv --rpc-url {rpc-url} --broadcast --verifier-url https://explorer.immutable.com/api --verifier blockscout --verify --gas-price 10000000000
4646
```
4747

4848
Optionally, you can also specify `--ledger` or `--trezor` for hardware deployments. See docs [here](https://book.getfoundry.sh/reference/forge/forge-script#wallet-options---hardware-wallet).

script/staking/common.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Load the .env file if it exists
3+
if [ -f .env ]
4+
then
5+
set -a; source .env; set +a
6+
fi
7+
8+
if [[ $useMainNet -eq 1 ]]
9+
then
10+
echo Immutable zkEVM Mainnet Configuration
11+
RPC=https://rpc.immutable.com
12+
BLOCKSCOUT_URI=https://explorer.immutable.com/api?
13+
USEMAINNET=true
14+
else
15+
echo Immutable zkEVM Testnet Configuration
16+
RPC=https://rpc.testnet.immutable.com
17+
BLOCKSCOUT_URI=https://explorer.testnet.immutable.com/api?
18+
USEMAINNET=false
19+
fi
20+
if [ -z "${BLOCKSCOUT_APIKEY}" ]; then
21+
echo "Error: BLOCKSCOUT_APIKEY environment variable is not set"
22+
exit 1
23+
fi
24+
25+
if [[ $useLedger -eq 1 ]]
26+
then
27+
echo " with Ledger Hardware Wallet"
28+
if [ -z "${LEDGER_HD_PATH}" ]; then
29+
echo "Error: LEDGER_HD_PATH environment variable is not set"
30+
exit 1
31+
fi
32+
else
33+
echo " with a raw private key"
34+
if [ -z "${PRIVATE_KEY}" ]; then
35+
echo "Error: PRIVATE_KEY environment variable is not set"
36+
exit 1
37+
fi
38+
fi
39+
40+
41+
echo "Configuration"
42+
echo " RPC: $RPC"
43+
echo " BLOCKSCOUT_APIKEY: $BLOCKSCOUT_APIKEY"
44+
echo " BLOCKSCOUT_URI: $BLOCKSCOUT_URI"
45+
if [[ $useLedger -eq 1 ]]
46+
then
47+
echo LEDGER_HD_PATH: $LEDGER_HD_PATH
48+
else
49+
echo " PRIVATE_KEY: <not echoed for your security>" # $PRIVATE_KEY
50+
fi

script/staking/deployComplex.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# useMainNet: 1 for mainnet, 0 for testnet
3+
useMainNet=0
4+
# useLedger: 1 for ledger, 0 for private key
5+
useLedger=0
6+
# Set-up variables
7+
source $(dirname "$0")/common.sh
8+
9+
10+
# NOTE WELL ---------------------------------------------
11+
# Add resume option if the script fails part way through:
12+
# --resume \
13+
# NOTE WELL ---------------------------------------------
14+
if [[ $useLedger -eq 1 ]]
15+
then
16+
forge script --rpc-url $RPC \
17+
--priority-gas-price 10000000000 \
18+
--with-gas-price 10000000100 \
19+
-vvv \
20+
--broadcast \
21+
--verify \
22+
--verifier blockscout \
23+
--verifier-url $BLOCKSCOUT_URI$BLOCKSCOUT_APIKEY \
24+
--sig "deployComplex()" \
25+
--ledger \
26+
--hd-paths "$LEDGER_HD_PATH" \
27+
script/staking/StakeHolderScript.t.sol:StakeHolderScript
28+
else
29+
forge script --rpc-url $RPC \
30+
--priority-gas-price 10000000000 \
31+
--with-gas-price 10000000100 \
32+
-vvv \
33+
--broadcast \
34+
--verify \
35+
--verifier blockscout \
36+
--verifier-url $BLOCKSCOUT_URI$BLOCKSCOUT_APIKEY \
37+
--sig "deployComplex()" \
38+
--private-key $PRIVATE_KEY \
39+
script/staking/StakeHolderScript.t.sol:StakeHolderScript
40+
fi
41+

script/staking/deploySimple.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# useMainNet: 1 for mainnet, 0 for testnet
3+
useMainNet=0
4+
# useLedger: 1 for ledger, 0 for private key
5+
useLedger=0
6+
# Set-up variables
7+
source $(dirname "$0")/common.sh
8+
9+
10+
# NOTE WELL ---------------------------------------------
11+
# Add resume option if the script fails part way through:
12+
# --resume \
13+
# NOTE WELL ---------------------------------------------
14+
if [[ $useLedger -eq 1 ]]
15+
then
16+
forge script --rpc-url $RPC \
17+
--priority-gas-price 10000000000 \
18+
--with-gas-price 10000000100 \
19+
-vvv \
20+
--broadcast \
21+
--verify \
22+
--verifier blockscout \
23+
--verifier-url $BLOCKSCOUT_URI$BLOCKSCOUT_APIKEY \
24+
--sig "deploySimple()" \
25+
--ledger \
26+
--hd-paths "$LEDGER_HD_PATH" \
27+
script/staking/StakeHolderScript.t.sol:StakeHolderScript
28+
else
29+
forge script --rpc-url $RPC \
30+
--priority-gas-price 10000000000 \
31+
--with-gas-price 10000000100 \
32+
-vvv \
33+
--broadcast \
34+
--verify \
35+
--verifier blockscout \
36+
--verifier-url $BLOCKSCOUT_URI$BLOCKSCOUT_APIKEY \
37+
--sig "deploySimple()" \
38+
--private-key $PRIVATE_KEY \
39+
script/staking/StakeHolderScript.t.sol:StakeHolderScript
40+
fi

0 commit comments

Comments
 (0)