1

The code runs but says "food.eth" is available (it isn't):

var Web3 = require("web3")
let web3 = new Web3(Web3.givenProvider || "ws://localhost:8546");
var ens = web3.eth.ens;
const words = [
    'beer',
    'food',
    'chovy',
];

(async () => {
    for (let word of words) {
        console.log('checking: '+ word);
        const addr = await getDomain(word);
        console.log(word+': '+ addr);
    }
})();

async function getDomain(word) {
    try {
        const addr = await ens.getAddress(`${word}.eth`)
        console.log(addr);
        return addr;
    } catch(err) {
        console.error(err);
        return;
    }
}

I'm running geth with the following command on Ubuntu 20.04:

geth --syncmode "light" --ws --mainnet

edit: From what I can tell after reading up, I need a "archive node" to query eth domains. Since the domain may not have been registered in the last 128 blocks (which is what a full node is).

Most of the cloud apis out there don't allow many queries for archive nodes.

edit: So apparently I have to set the resolver for the call to work:

const resolv = await getResolver(word);
await ens.setResolver(`${word}.eth`, resolv);

async function getResolver(word) {
    try {
        const resolv = await ens.getResolver(`${word}.eth`);
        console.log('found resolver: ', resolv._address);
        return resolv._address;
    } catch(err) {
        console.error(err, 'resolver error');
        return;
    }
}

But now I get this error:

$ node index.js       
found resolver:  0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41
(node:426847) UnhandledPromiseRejectionWarning: Error: No "from" address specified in neither the given options, nor the default options.
    at Object.ContractNoFromAddressDefinedError (/home/ubuntu/www/eth/node_modules/web3-core-helpers/lib/errors.js:125:16)
    at Object._executeMethod (/home/ubuntu/www/eth/node_modules/web3-eth-contract/lib/index.js:772:48)
    at /home/ubuntu/www/eth/node_modules/web3-eth-ens/lib/contracts/Registry.js:461:109
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
3
  • archival node takes 8TB of space
    – Nulik
    Aug 26, 2021 at 12:58
  • 1
    ENS queries are just contract Call()s , full node is fine
    – Nulik
    Aug 26, 2021 at 12:58
  • will a light node work or must it be full node?
    – chovy
    Aug 26, 2021 at 13:03

1 Answer 1

0

The geth light sync mode might not have the required state information to give you the right answer. Because it has not fetched the state that tells whether the name is registered, it defaults to unregistered.

Instead, do a snap sync for your node.

10
  • so add --snap to my geth command?
    – chovy
    Aug 26, 2021 at 10:29
  • I only have 30gb space total...will light node not work for getting accurate results?
    – chovy
    Aug 26, 2021 at 10:30
  • That is not going to work, because the size of Ethereum state is more than 30 gigabytes. You cannot query the state if it doesn't fit on your computer. Aug 26, 2021 at 10:32
  • 1
    Just use an external free node API like CloudFlare: ethereumnodes.com Aug 26, 2021 at 10:34
  • what web socket address do I use?
    – chovy
    Aug 26, 2021 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.