This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { utils } = require('ethers') | |
const fetch = require('cross-fetch') | |
const name = 'coin-mountain.argent.xyz' | |
const namehash = name => | |
name | |
.split('.') | |
.reverse() | |
.reduce((parentHash, label) => { | |
console.log('parent hash:', utils.hexlify(parentHash)) | |
console.log('label:', label) | |
return utils.solidityKeccak256( | |
['bytes', 'bytes'], | |
[parentHash, utils.solidityKeccak256(['string'], [label])] | |
) | |
}, utils.formatBytes32String('')) | |
const run = async () => { | |
let response = await fetch('https://api.thegraph.com/subgraphs/name/ensdomains/ens', { | |
method: 'POST', | |
headers: { | |
'content-type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
query: | |
'query domain($id: ID!) { domain(id: $id) { id labelhash name parent { id labelhash name parent { id labelhash name } } } }', | |
variables: { id: namehash(name) }, | |
}), | |
}) | |
let data = await response.json() | |
console.log(JSON.stringify(data, undefined, 2)) | |
} | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: