import Web3 from "web3";
useEffect(() => {
const web3 = new Web3(window.ethereum);
web3.eth.ens.getAddress("ethereum.eth").then(function (address) {
console.log(address);
});
}, []);
here using this code i am getting address
from ether name is there any way i can get name from address
web3.eth.ens.getOwner("0xc74E8eFaFE54481bD109f97422AeBca607499f57").then(function (address) {
console.log(address);
});
I am trying above piece of code but it is not working if i input 0xc74E8eFaFE54481bD109f97422AeBca607499f57
i should get ethereum.eth
please take a look how can i get this
As you can see from the ENS documentation , web3.js can't performed "reversed resolution", ie getting a ENS name from an address. However, you can do this from the ensjs API like this:
const address = '0xc74E8eFaFE54481bD109f97422AeBca607499f57';
var name = await ens.getName(address)
// Check to be sure the reverse record is correct.
if(address != await ens.name(name).getAddress()) {
name = null;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.