Herotag script and how can a script can go over herotags and resolves them automatically to addresses

77 views Asked by At

Does anyone have a script that goes over herotags and resolves them automatically to addresses?

I don't want to manually enter a herotag to elrondscan.com everytime to get the address - and the explorer.multiversx.com interestingly doesnt resolve some herotags, while elrondscan.com does.

2

There are 2 answers

0
Quentin On

You can achieve this using mxpy:

  1. Install mxpy: https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/
  2. Run the command mxpy dns resolve <the herotag with the .elrond suffix> --proxy <gateway_url>

Example with wonjae, a random herotag I saw on the explorer:

Command: mxpy dns resolve wonjae.elrond --proxy https://gateway.multiversx.com

Output: erd1dma9eq8626gezj4360ylleet8mmq02v0eyzp2syth0f08p5epf2sgmedkl

Here is a sample script which iterates over herotags to resolve their address:

#!/bin/bash

# Define the list of herotags
herotags=("wonjae" "liger") # Add more herotags as needed

# Function to extract the last word starting with "erd1"
extract_last_erd1_word() {
    local output="$1"
    echo "$output" | grep -o '\berd1\w*' | tail -1
}

# Iterate over the herotags
for str in "${herotags[@]}"; do
    # Run the mxpy command and capture its output
    output=$(mxpy dns resolve "${str}.elrond" --proxy https://gateway.multiversx.com)

    # Extract the last word starting with "erd1"
    last_erd1_word=$(extract_last_erd1_word "$output")

    # Output the result
    echo "Address of ${str}: $last_erd1_word"
done
0
PhyloFane On

To explain this:

the explorer.multiversx.com interestingly doesnt resolve some herotags, while elrondscan.com does.

From what I know, explorer.multiversx.com respects the 'Public account' setting in the xPortal application, and probably elrondscan does not.

That's likely why you are having trouble resolving some herotags on explorer.multiversx.com.