Here is a small collection of scripts and shell aliases designed to perform some very basic but very common and useful functions. These quick simple tools are meant to relieve a bit of the tedious repetative tasks when debugging or exploring information or applications on the Sei network.
-
Clone or Copy Scripts: Save the provided scripts into your preferred directory (e.g.,
$HOME/scripts/
). Ensure each file is executable:chmod +x $HOME/scripts/*.sh
-
Add Aliases to Shell Config: Add the following aliases to your shell configuration file (e.g.,
~/.bashrc
for Bash or~/.config/fish/config.fish
for Fish shell):alias b64='bash $HOME/scripts/b64.sh' alias h2d='node $HOME/scripts/js/hextodec.js' alias d2h='node $HOME/scripts/js/dectohex.js' alias assocwallet='bash $HOME/scripts/associated_wallet.sh' alias crosstx='bash $HOME/scripts/cross_txhash.sh'
-
Reload Shell Configuration: Apply the changes:
source ~/.bashrc
-
Define Environment Variables: Set the necessary RPC endpoint environment variables:
export SEIEVM="<EVM_RPC_URL>" export SEIRPC="<TENDERMINT_RPC_URL>"
Script: $HOME/scripts/b64.sh
Alias: b64
Purpose: Decodes base64-encoded data, extracting printable characters for easier readability and debugging.
Script Content:
#!/bin/bash
DATA=$1
echo "$DATA" | base64 --decode | strings
Usage:
b64 "<base64_data>"
Script: $HOME/scripts/js/hextodec.js
Alias: h2d
Purpose: Converts a hexadecimal string to its decimal equivalent, useful for interpreting numerical data in EVM logs or transactions.
Script Content:
// Function to convert a hexadecimal string to a decimal number
function hexToDecimal(hexString) {
if (typeof hexString !== 'string' || hexString.trim() === '') {
console.error("Please provide a valid hexadecimal string.");
return;
}
let decimalValue = parseInt(hexString, 16);
if (isNaN(decimalValue)) {
console.error("Invalid hexadecimal string. Could not convert to decimal.");
} else {
console.log(`Hexadecimal: ${hexString}`);
console.log(`Decimal: ${decimalValue}`);
}
}
const hexInput = process.argv[2];
if (hexInput) {
hexToDecimal(hexInput);
} else {
console.log("Usage: node hextodec.js <hexString>");
}
Usage:
h2d <hexadecimal_value>
Script: $HOME/scripts/js/dectohex.js
Alias: d2h
Purpose: Converts a decimal number to its hexadecimal representation, often needed for crafting EVM-compatible data.
Script Content:
// Function to convert a decimal number to a hexadecimal string
function decimalToHex(decimalNumber) {
if (isNaN(decimalNumber)) {
console.error("Please provide a valid decimal number.");
return;
}
let hexValue = parseInt(decimalNumber).toString(16);
console.log(`Decimal: ${decimalNumber}`);
console.log(`Hexadecimal: 0x${hexValue}`);
}
const decimalInput = process.argv[2];
if (decimalInput) {
decimalToHex(decimalInput);
} else {
console.log("Usage: node dectohex.js <decimalNumber>");
}
Usage:
d2h <decimal_value>
Script: $HOME/scripts/associated_wallet.sh
Alias: assocwallet
Purpose: Checks for an associated address for a given wallet. Supports conversion between Bech32 (Cosmos) and Hex (EVM) addresses.
Script Content:
#!/bin/bash
ADDRESS=$1
if [[ $ADDRESS == 0x* ]]; then
curl -X POST "$SEIEVM" -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"sei_getSeiAddress","params":["'$ADDRESS'"],"id":1}'
elif [[ $ADDRESS == sei* ]]; then
curl -X POST "$SEIEVM" -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"sei_getEVMAddress","params":["'$ADDRESS'"],"id":1}'
else
echo "Invalid address format. Provide a Bech32 or Hex address."
fi
Usage:
- Bech32 to Hex:
assocwallet sei1...
- Hex to Bech32:
assocwallet 0x...
Script: $HOME/scripts/cross_txhash.sh
Alias: crosstx
Purpose: Fetches the corresponding transaction hash when moving between EVM and Cosmos environments.
Script Content:
#!/bin/bash
TX_HASH=$1
if [[ $TX_HASH == 0x* ]]; then
curl -X POST "$SEIEVM" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"sei_getCosmosTx","params":["'$TX_HASH'"],"id":1}'
elif [[ $TX_HASH == *txhash* ]]; then
curl -X POST "$SEIEVM" -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"sei_getEvmTx","params":["'$TX_HASH'"],"id":1}'
else
echo "Invalid transaction hash format. Provide an EVM or Tendermint transaction hash."
fi
Usage:
- EVM to Tendermint:
crosstx 0x...
- Tendermint to EVM:
crosstx txhash...
Quickly identify if a wallet address is associated across environments (Bech32 <-> Hex) to ensure interoperability.
Trace transaction hashes between EVM and Cosmos environments to diagnose discrepancies or missing links.
Facilitate conversion of numerical data formats (hex/decimal) to debug logs or transactions more effectively.
Decode encoded data, such as smart contract payloads or debug messages, into human-readable format.
- These tools rely on RPC endpoints ($SEIEVM, $SEIRPC). Ensure they are correctly configured and reachable. Any public endpoints should work here.
- Each script is lightweight and intended for quick troubleshooting, not for production-level automation.
- Always verify data outputs, especially when debugging critical issues.