11#! /bin/bash
22
3- if [[ -z " $RPC_URL " ]]; then
4- echo " RPC_URL is empty, using default value http://localhost:8545"
5- RPC_URL=" http://localhost:8545"
6- fi ;
7-
8- # check that OPERATOR_ADDRESS is not empty
9- if [[ -z " $OPERATOR_ADDRESS " ]]; then
10- echo " OPERATOR_ADDRESS is empty, using default value 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
11- OPERATOR_ADDRESS=" 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
12- fi ;
13-
14- # Check that the script received 2 arguments
15- if [[ " $# " -ne 2 ]]; then
16- echo " Usage: $0 <config_file> <amount>"
17- exit 1
18- fi ;
19-
20- mock_strategy_address=$( cat " contracts/script/output/devnet/eigenlayer_deployment_output.json" | jq -r ' .addresses.strategies.WETH' )
21- mock_token_address=$( cast call " $mock_strategy_address " " underlyingToken()" --rpc-url " $RPC_URL " )
22-
23- operator_address=$( cat " $1 " | yq -r ' .operator.address' )
24-
25- if [[ -z " $mock_token_address " ]]; then
26- echo " Mock token address is empty, please deploy the contracts first"
27- exit 1
28- fi ;
29-
30-
31- # Remove 0x prefix from mock token address
32- mock_token_address=$( echo " $mock_token_address " | sed ' s/^0x//' )
33-
34- stripped=$( echo " $mock_token_address " | sed ' s/^0*//' )
35-
36- # Add back a single leading zero if the original string had any leading zeros
37- if [[ " $mock_token_address " =~ ^0+ ]]; then
38- mock_token_address=" 0$stripped "
39- else
40- mock_token_address=" $stripped "
41- fi
42-
43- echo " Minting $2 tokens to $operator_address "
44- echo " Mock token address: $mock_token_address "
45-
46- # Ethereum sender address - anvil address 1
47- private_key=" 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
48-
49- # Mint tokens
50- # The deployment `contracts/eigenlayer_contracts/eigenlayer-contracts/script/deploy/local/deploy_from_scratch.slashing.s.sol`
51- # send tokens to `executorMultisig` which is `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` (Anvil address 1)
52- # We need to send tokens from `executorMultisig` to `operator_address`
53- cast send " $mock_token_address " \
54- " transfer(address recipient, uint256 amount)(bool)" \
55- " $operator_address " " $2 " \
56- --private-key $private_key \
57- --rpc-url $RPC_URL
3+ # Configuration
4+ PRIVATE_KEY=" 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
5+ DEFAULT_RPC_URL=" http://localhost:8545"
6+ DEPLOYMENT_FILE=" contracts/script/output/devnet/eigenlayer_deployment_output.json"
7+
8+ # Function to validate input arguments
9+ validate_args () {
10+ if [[ " $# " -ne 2 ]]; then
11+ echo " Usage: $0 <config_file> <amount>"
12+ exit 1
13+ fi
14+ }
15+
16+ # Function to set RPC_URL
17+ set_rpc_url () {
18+ RPC_URL=${RPC_URL:- $DEFAULT_RPC_URL }
19+ echo " Using RPC_URL: $RPC_URL "
20+ }
21+
22+ # Function to get operator address from config file
23+ get_operator_address () {
24+ local config_file=" $1 "
25+ OPERATOR_ADDRESS=$( yq -r ' .operator.address' " $config_file " )
26+ if [[ -z " $OPERATOR_ADDRESS " ]]; then
27+ echo " Error: Could not read operator address from $config_file "
28+ exit 1
29+ fi
30+ }
31+
32+ # Function to normalize address (remove 0x prefix and handle leading zeros)
33+ normalize_address () {
34+ local address=$1
35+ # Remove '0x' prefix, take last 40 characters, then add '0x' back
36+ echo " 0x$( echo " $address " | sed ' s/^0x//' | tail -c 41) "
37+ }
38+
39+ # Function to get mock token address
40+ get_mock_token_address () {
41+ local strategy_type=" $1 "
42+ local mock_strategy_address=$( jq -r " .addresses.strategies.$strategy_type " " $DEPLOYMENT_FILE " )
43+ local mock_token_address=$( cast call " $mock_strategy_address " " underlyingToken()" --rpc-url " $RPC_URL " )
44+
45+ if [[ -z " $mock_token_address " ]]; then
46+ echo " Error: Mock token address is empty for $strategy_type . Please deploy contracts first."
47+ exit 1
48+ fi
49+
50+ normalize_address " $mock_token_address "
51+ }
52+
53+ # Function to mint tokens
54+ mint_tokens () {
55+ local token_address=" $1 "
56+ local recipient=" $2 "
57+ local amount=" $3 "
58+
59+ echo " Minting $amount tokens to $recipient "
60+ echo " Token address: $token_address "
61+
62+ cast send " $token_address " \
63+ " transfer(address recipient, uint256 amount)(bool)" \
64+ " $recipient " " $amount " \
65+ --private-key " $PRIVATE_KEY " \
66+ --rpc-url " $RPC_URL "
67+ }
68+
69+ # Main execution
70+ main () {
71+ validate_args " $@ "
72+ set_rpc_url
73+
74+ local config_file=" $1 "
75+ local amount=" $2 "
76+
77+ get_operator_address " $config_file "
78+
79+ # Mint WETH tokens
80+ local weth_token_address=$( get_mock_token_address " WETH" )
81+ mint_tokens " $weth_token_address " " $OPERATOR_ADDRESS " " $amount "
82+
83+ # Mint ALI tokens
84+ local ali_token_address=$( get_mock_token_address " ALI" )
85+ mint_tokens " $ali_token_address " " $OPERATOR_ADDRESS " " $amount "
86+ }
87+
88+ # Execute main function
89+ main " $@ "
0 commit comments