
The author: Takahashi Kaito
Have you ever wondered how to retrieve all the Ethereum Name Service (ENS) domain names owned by a specific wallet address? In this article, we will guide you through the process of obtaining ENS domains using the Chainbase getAccountENS API. Whether you’re a developer or an enthusiast interested in exploring ENS ownership, this step-by-step tutorial will provide you with the necessary tools and instructions.
Before we dive into the process of retrieving ENS domain names, let’s ensure we have the necessary tools in place. Here’s what you’ll need:
With these tools at your disposal, you’re ready to proceed to the next steps.
To make the most of Chainbase’s capabilities, you should register for a free account on their platform. Follow these steps:
Now that you have a Chainbase account and an API key, it’s time to write a script that interacts with the Chainbase getAccountENS API. We’ll provide examples using both the fetch and axios libraries in JavaScript. Choose the one that suits your preferences or existing project setup.
Using fetch in JavaScript
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.
wallet_addr = '0x57511688c0ca7Cc7C25B90aE51C62B64652136Ac'; // Take our CTO Xiaocong's wallet address as an example.
fetch(`https://api.chainbase.online/v1/account/ens?chain_id=${network_id}&address=${wallet_addr}`, {
method: 'GET',
headers: {
'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key.
'accept': 'application/json'
}
}).then(response => response.json())
.then(data => console.log(data.data))
.catch(error => console.error(error));Using axios in JavaScript
First, install axios by running npm install axios --save in your terminal.
network_id = '1'; // See https://docs.chainbase.com/reference/supported-chains to get the id of different chains.
wallet_addr = '0x57511688c0ca7Cc7C25B90aE51C62B64652136Ac'; // Take our CTO Xiaocong's wallet address as an example.
const axios = require('axios');
const options = {
url: `https://api.chainbase.online/v1/account/ens?chain_id=${network_id}&address=${wallet_addr}`,
method: 'GET',
headers: {
'x-api-key': CHAINBASE_API_KEY, // Replace the field with your API key.
'accept': 'application/json'
}
};
axios(options)
.then(response => console.log(response.data.data))
.catch(error => console.log(error));Choose the appropriate code snippet based on your preference and execute it in your IDE. This script will retrieve the ENS domains associated with the provided wallet address.
To get data printed, run command node <filename>.js in the terminal.
After executing the script, you will receive a response containing the ENS domain names owned by the provided wallet address. The response will be in JSON format, and here’s an example:
[
{
"address": "0x57511688c0ca7cc7c25b90ae51c62b64652136ac",
"expiration_time": "2023-04-17T14:19:21Z",
"name": "lxcong",
"owner": "0x57511688c0ca7Cc7C25B90aE51C62B64652136Ac",
"registrant": "0x57511688c0ca7cc7c25b90ae51c62b64652136ac",
"registrant_time": "2022-04-17T08:30:09Z",
"resolver": "0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41",
"text_records": {},
"token_id": "63135721284494715790867739452503301817186787830065141439742276093364926543362"
}
]
The response contains information such as the address, expiration time, name, owner, registrant, resolver, text records, and token ID for each ENS domain.
Retrieving ENS domain names associated with a specific wallet address is made easy with the Chainbase getAccountENS API. By following the steps outlined in this article, you can obtain valuable information about ENS ownership. Start exploring the ENS ecosystem and discover the fascinating world of decentralized naming systems.
Remember, Chainbase offers a range of APIs and features beyond what we covered here. Refer to their documentation for further details and explore the possibilities.
Our Chainbase getAccountENS API is an endpoint that allows you to retrieve all Ethereum Name Service (ENS) domain names owned by a specific wallet address. By providing the chain ID and wallet address as parameters, you can access valuable information about ENS ownership.
Currently, Chainbase primarily supports Ethereum chains. You can utilize Chainbase and its APIs to interact with Ethereum-based wallets and retrieve ENS domain data. For other blockchain ecosystems, refer to the specific tools and services available for those platforms such as spaceID in bsc.
Yes, we offer free account option that provides access to our APIs and data cloud. However, we also have additional premium features or plans for advanced usage.
Yes, as long as you have the wallet address for which you want to retrieve the ENS domains, you can use our Chainbase getAccountENS API to obtain the relevant information. The API provides ENS domain details specific to the provided wallet address.
The ENS domain ownership data provided by our Chainbase getAccountENS API is based on the latest information available on the Ethereum blockchain. As blockchain data is immutable, the ownership data is as accurate and up-to-date as the underlying blockchain network. However, individual ENS domain owners may update their domain settings, so it’s advisable to consider potential changes over time.
Chainbase is an all-in-one data infrastructure for Web3 that allows you to index, transform, and use on-chain data at scale. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase automates the indexing and querying of blockchain data, enabling developers to accomplish more with less effort.
Visit our website chainbase.com Sign up for a free account, and Check out our documentation.
Website|Blog|Twitter|Discord|Link3
Original Link: How to Get All ENS Domain Names by an Address
【免责声明】市场有风险,投资需谨慎。本文不构成投资建议,用户应考虑本文中的任何意见、观点或结论是否符合其特定状况。据此投资,责任自负。
