git clone https://github.com/ensdomains/reverse-records
cd reverse-records
cp env.example .env // Add your mnemonic, infura project id, and etherscan key
yarn
yarn query:ropsten 0x123...,0x234...
Returns an array of string. If the given address does not have a reverse record or forward record setup, it returns an empty string.
Make sure to compare that the returned names match with the normalised names to prevent from homograph attack
Example
const namehash = require('eth-ens-namehash');
const allnames = await ReverseRecords.getNames(['0x123','0x124'])
const validNames = allnames.filter((n) => namehash.normalize(n) === n )