2

I'm using the library: https://www.npmjs.com/package/eth-ens-namehash to try to generate an ID so I can look up an ENS domain's expiration date on the base registrar implementation.

if I hash "vitalik.eth" I get "0xee6c4522aab0003e8d14cd40a6af439055fd2577951148c14b6cea9a53475835"

var namehash = require('eth-ens-namehash')
var hash = namehash.hash('vitalik.eth')

If I query nameExpires at: https://etherscan.io/address/0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85#readContract

it returns 0 because it can't find it. I looked up the same record on thegraph: https://thegraph.com/legacy-explorer/subgraph/ensdomains/ens

{
  domains(where: {name:"vitalik.eth"}) {
    id
    name
    labelName
    labelhash
  }
}

I see the id/namehash, but I also see a labelhash: 0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc

{
  "data": {
    "domains": [
      {
        "id": "0xee6c4522aab0003e8d14cd40a6af439055fd2577951148c14b6cea9a53475835",
        "labelName": "vitalik",
        "labelhash": "0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc",
        "name": "vitalik.eth"
      }
    ]
  }
}

if I query this inside etherscan, I get the expiration date: 1935676872.

My question is, how do I get to that correct hash programmatically so I can query the expiration date properly?

2
  • 0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc is just a keccak on the word vitalik
    – Nulik
    Aug 13, 2021 at 1:12
  • make it an answer and I'll give you credit
    – Dobit
    Aug 13, 2021 at 16:56

1 Answer 1

1

Use keccak package. A sample will be as shown below.

const keccakHelper = require("keccak");
console.log(keccakHelper("keccak256").update("vitalik").digest("hex"));

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.