Skip to content

Commit

Permalink
add mainnet checker
Browse files Browse the repository at this point in the history
  • Loading branch information
danoctavian committed Aug 16, 2024
1 parent 93002ba commit 5b36c84
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions script/verification/verify-bytecode-ynlsde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ DEPLOYMENT_FILE="./deployments/YnLSDe-1.json"
# List of contracts to verify
contracts=("YnLSDe" "assetRegistry" "eigenStrategyManager" "tokenStakingNodesManager" "ynEigenDepositAdapter" "rateProvider" "ynEigenViewer")

# Read the Etherscan API key from .env file
ETHERSCAN_API_KEY=$(grep ETHERSCAN_API_KEY .env | cut -d '=' -f2 | tr -d '[:space:]')

# Log ETHERSCAN_API_KEY (masked for security)
echo "ETHERSCAN_API_KEY: ${ETHERSCAN_API_KEY:0:4}...${ETHERSCAN_API_KEY: -4}"


get_solidity_contract_name() {
local contract_key=$1
Expand Down Expand Up @@ -59,16 +65,14 @@ verify_contract() {
echo "Verifying $contract_name (Solidity contract: $solidity_contract)..."

# Get bytecode from Etherscan
local etherscan_bytecode=$(curl -s -X GET "https://api.etherscan.io/api?module=proxy&action=eth_getCode&address=$impl_address&tag=latest&apikey=$ETHERSCAN_API_KEY" | jq -r '.result')

# Calculate SHA256 of Etherscan bytecode
local etherscan_sha256=$(echo -n "$etherscan_bytecode" | sed 's/0x//' | xxd -r -p | sha256sum | awk '{print $1}')
local etherscan_sha256=$(curl -X GET "https://api.etherscan.io/api?module=proxy&action=eth_getCode&address=$impl_address&tag=latest&apikey=$ETHERSCAN_API_KEY" | jq -r '.result' | sha256sum)

# Log the implementation address and its SHA256 hash
echo "Implementation address for $contract_name: $impl_address"
echo "Etherscan bytecode SHA256 for $contract_name: $etherscan_sha256"

# Get local bytecode
local local_bytecode=$(cat "out/$solidity_contract.sol/$solidity_contract.json" | jq -r '.deployedBytecode.object')

# Calculate SHA256 of local bytecode
local local_sha256=$(echo -n "$local_bytecode" | xxd -r -p | sha256sum | awk '{print $1}')
local local_sha256=$(cat "out/$solidity_contract.sol/$solidity_contract.json" | jq -r '.deployedBytecode.object' | sed 's/"//g' | sha256sum)

# Compare SHA256 hashes
if [ "$etherscan_sha256" = "$local_sha256" ]; then
Expand Down

0 comments on commit 5b36c84

Please sign in to comment.