-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENS reverse lookup #2683
Comments
@nivida I think the ENS registry is also missing. you can add in this issue or if you want I can create a new issue. |
The ens registry isn't missing. https://web3js.readthedocs.io/en/1.0/web3-eth-ens.html#registry |
Yep, there are some missing new methods. I was in contact with the ENS team and told them to check it. I'll do this together with the ENS reverse lookup because it isn't a big thing to add these methods. The current registry: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-eth-ens/src/contracts/Registry.js |
Is the reverse on the roadmap? or can we create a PR ? |
This would be great, I see its be flagged for the |
It would be really awesome if this was priorities to be fixed - the current way, from my understanding, to allow users to claim subdomains on ENS is to send them to the ENS manager site or write some custom code, would be great if this was part of native we3js |
I've created a code snippet to do a reverse lookup. async function Reverse(address) {
var lookup=address.toLowerCase().substr(2) + '.addr.reverse'
var ResolverContract=await web3.eth.ens.resolver(lookup);
var nh=namehash.hash(lookup);
var name=await ResolverContract.methods.name(nh).call()
return name;
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions |
@x48-crypto check this comment |
any update? |
Here is a snippet of the above with the recommended forward lookup to avoid imposters: async function reverseENSLookup(address: string, web3: Web3) {
let lookup = address.toLowerCase().substr(2) + '.addr.reverse'
let ResolverContract = await web3.eth.ens.getResolver(lookup);
let nh = namehash.hash(lookup);
try {
let name = await ResolverContract.methods.name(nh).call();
if (name && name.length) {
const verifiedAddress = await web3.eth.ens.getAddress(name);
if (verifiedAddress && verifiedAddress.toLowerCase() === address.toLowerCase()) {
return name;
}
}
} catch(e) { }
} |
I am trying to implement your snippet using Web3JS from a CDN but I am getting an error "namehash: is not defined". The namehash object appears to be implemented in the library but I am not able to call it. Apparently I am missing something... |
Namehash can be found here: https://www.npmjs.com/package/@ensdomains/eth-ens-namehash |
I didn't want to import any extra modules to my frontend so I use this function: async function ensReverse(address) {
const web3 = new Web3('https://eth.public-rpc.com/');
const namehash = await web3.eth.call({
to: '0x084b1c3c81545d370f3634392de611caabff8148', // ENS: Reverse Registrar
data: web3.eth.abi.encodeFunctionCall({
name: 'node', type: 'function',
inputs: [{type: 'address', name: 'addr'}]
}, [address])
});
return web3.eth.abi.decodeParameter('string', await web3.eth.call({
to: '0xa2c122be93b0074270ebee7f6b7292c7deb45047', // ENS: Default Reverse Resolver
data: web3.eth.abi.encodeFunctionCall({
name: 'name', type: 'function',
inputs: [{type: 'bytes32', name: 'hash'}]
}, [namehash])
}));
} |
Description
Implement the ENS reverse lookup.
Docs: https://docs.ens.domains/contract-api-reference/reverseregistrar
The text was updated successfully, but these errors were encountered: