I'm trying to both resolve and lookup using "ethjs-ens" the lookup call is working correctly. However, the resolve
call is throwing an empty error.
The address I'm using on the reverse
function is the one I got from calling lookup
, I'm also logging a validation to check that both addresses are the same console.log("is the same", address === result);
import ENS from "ethjs-ens";
//assume metamask installed
//testing on main network
const ens = new ENS({ provider: window.web3.currentProvider, network: 1 });
const address = "0x96619cd92fe0c7deaaee1c8043a7fea79cfa3e71";
const name = "example.eth";
const fn = async () => {
try {
const result = await ens.lookup(name);
console.log("adddress", result);
console.log("is the same", address === result);
} catch (e) {
console.log("lookup", e);
}
try {
const resultName = await ens.reverse(address);
console.log("name is", resultName);
} catch (e) {
console.log("name", e);
}
};
fn();
reverse
is always failing not sure what could be happening.
I was wanting to get the reverse lookup and was running into issues with ethjs-ens
as well as ethereum-ens
packages. Ended up going with ethers
. This worked for me:
import { ethers } from 'ethers';
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const name = await provider.lookupAddress(address);