Search code examples
blockchainmultiversx

How can I get the wallet address for a given herotag?


If I want to get the herotag for a given wallet address, I can simply call the following endpoint:

https://api.elrond.com/accounts/erd1hw78kxyj353x52hmmq6dzxgexynwt4m29q2uvpq6xdm90z3halvsl7cn6g

and I get:

{
   "address":"erd1hw78kxyj353x52hmmq6dzxgexynwt4m29q2uvpq6xdm90z3halvsl7cn6g",
   "nonce":4,
   "balance":"0",
   "rootHash":"QU6o17Qw4KUPnpU6e6QbEuvKUTA8SPy52QFseslWsG4=",
   "txCount":4,
   "username":"event.elrond",
   "shard":1
}

where I see the username.

But now I'd like to obtain the wallet address for a given herotag.

Is there any API endpoint for this purpose?


Solution

  • Using API

    https://api.elrond.com/usernames/<herotag>
    

    E.g.:

    https://api.elrond.com/usernames/event

    redirects to

    https://api.elrond.com/accounts/erd1hw78kxyj353x52hmmq6dzxgexynwt4m29q2uvpq6xdm90z3halvsl7cn6g

    and returns

    {
      "address": "erd1hw78kxyj353x52hmmq6dzxgexynwt4m29q2uvpq6xdm90z3halvsl7cn6g",
      "nonce": 7,
      "balance": "254914476000000000",
      "rootHash": "QU6o17Qw4KUPnpU6e6QbEuvKUTA8SPy52QFseslWsG4=",
      "txCount": 9,
      "scrCount": 12,
      "username": "event.elrond",
      "shard": 1,
      "developerReward": "0"
    }
    

    Using erdpy

    erdpy dns resolve <herotag>.elrond --proxy=https://gateway.elrond.com
    

    where <herotag> should be replaced by its value.

    E.g.:

    erdpy dns resolve event.elrond --proxy=https://gateway.elrond.com
    

    outputs

    erd1hw78kxyj353x52hmmq6dzxgexynwt4m29q2uvpq6xdm90z3halvsl7cn6g
    

    Details:

    $ erdpy --version
    erdpy 1.0.12