Lookup Crypto Address Using ODude Name
ODude Name simplifies the resolution of crypto addresses, enabling seamless integration into your Web3 applications. This guide will walk you through retrieving wallet addresses from ODude Names.
Prerequisites
Before proceeding, ensure you have:
- Node.js installed (v14 or later recommended)
- NPM or Yarn installed
- A blockchain RPC provider (e.g., Alchemy, Infura, or QuickNode)
- Environment variables configured (optional but recommended)
Step 1: Install the Required Package
To get started, install @odude/oduderesolve
using npm or yarn:
npm install @odude/oduderesolve
or
yarn add @odude/oduderesolve
Step 2: Set Up Configuration
To interact with ODude Name, you need to provide blockchain RPC URLs and a wallet private key. This can be done via environment variables or directly in the code.
require('dotenv').config(); // Remove this line if no environment variables are used
const ODudeName = require("@odude/oduderesolve");
const settings = {
matic_rpc_url: process.env.MATIC_RPC,
eth_rpc_url: process.env.ETH_RPC,
fvm_rpc_url: process.env.FVM_RPC,
wallet_pvt_key: process.env.PVT_KEY
};
const resolve = new ODudeName(settings);
Step 3: Retrieve Wallet Address from ODude Name
You can fetch the wallet address linked to an ODude Name using getAddress()
.
resolve.getAddress("hello@web3", "ETH").then(address => {
console.log("Wallet address of hello@web3 is: ", address);
}).catch(console.error);
Additional Examples:
resolve.getAddress("web3", "ETH").then(address => {
console.log("Wallet address of @web3 is: ", address);
}).catch(console.error);
resolve.getAddress("hello@fil", "ETH").then(address => {
console.log("Wallet address of hello@fil is: ", address);
}).catch(console.error);
resolve.getAddress("ttttttttttttttttt@web3", "ETH").then(address => {
console.log("Wallet address of non-existent name: ", address);
}).catch(console.error);
Step 4: Running the Script
Save the script in a file (e.g., lookup_address.js
) and run it with:
node lookup_address.js
Conclusion
By using ODude Name, you can seamlessly resolve Web3 domain names into crypto wallet addresses. This simplifies blockchain transactions and enhances user experience.
For more advanced use cases, visit the ODude Name GitHub repository.
Happy coding! 🚀