This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
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.
get chain-id automatically in deploy-ipc (#184)
* get chain-id automatically in deploy-ipc * IPC-184: check if chain-id is valid
- Loading branch information
Showing
6 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
#!/bin/bash | ||
|
||
# Check if RPC_URL is set | ||
if [[ -z "$RPC_URL" ]]; then | ||
echo "RPC_URL is not set. Sourcing .env file..." | ||
source .env | ||
fi | ||
|
||
# Make a JSON-RPC call to get the chain ID using curl | ||
response=$(curl -s -X POST -H "Content-Type: application/json" --data '{ | ||
"jsonrpc":"2.0", | ||
"method":"eth_chainId", | ||
"params":[], | ||
"id":1 | ||
}' $RPC_URL) | ||
|
||
# Extract the chain ID from the response using jq (ensure jq is installed) | ||
chain_id=$(echo $response | jq -r '.result') | ||
|
||
# Double-check that this is a valid chain-id | ||
if [[ "$chain_id" =~ ^0x[0-9a-fA-F]+$ ]]; then | ||
# Export the chain ID as an environmental variable | ||
export CHAIN_ID=$chain_id | ||
# Print the chain ID for verification (optional) | ||
echo "[*] Target network Chain ID: $CHAIN_ID" | ||
else | ||
echo "[*] Error getting a valid hexadecimal chain ID" | ||
exit 1 | ||
fi |
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