Skip to content

IPNS contenthash decoding strips first character from peer ID #4527

@eth-limo

Description

@eth-limo

Ethers Version

6.9.1

Search Terms

ipns, contenthash

Describe the Problem

When attempting to decode a contentHash record set to an IPNS peer ID, the first character is stripped, resulting in an unparsable IPNS pointer:

For example (esteroids.eth):

Wrong: ipns://2D3KooWKrB93pwXDdeyz2WRMwcSBny5ECjA1JasB4GTo4ijUUtf

Should be: ipns://12D3KooWKrB93pwXDdeyz2WRMwcSBny5ECjA1JasB4GTo4ijUUtf

Code Snippet

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider(process.env.ETH_RPC_ENDPOINT);

async function lookup(ens) {
  let hostname = ens
  var res = await provider.getResolver(hostname);
  var contentHash = await res.getContentHash();
  var address = await res.getAddress();

  var output = JSON.stringify({
    resolver: res,
    address: address,
    contentHash: contentHash,
  });
  console.log(output);
}

lookup("esteroids.eth");

Contract ABI

No response

Errors

No response

Environment

node.js (v12 or newer)

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions