Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to extract image URL from ens avatar text record

When using ethers JavaScript library to retrieve ENS text records from the Ethereum Name Service. I got the NFT URI from the text record but not the image URL. Please is there any way/service to convert this metadata URI to an HTTPS image URL.

TO RECREATE:

TERMINAL : npm install --save ethers

Code:

var ethers = require('ethers');
var url = 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161';
var provider = new ethers.providers.JsonRpcProvider(url);


async function main() {
    const resolver = await provider.getResolver("brantly.eth");
    const avatar = await resolver.getAvatar();
    const avatarMetaData = await resolver.getText("avatar");
    console.log(`Avatar Metadata: ${avatarMetaData}`);
}

main();

.

Output: Avatar Metadata: eip155:1/erc721:0xb7F7F6C52F2e2fdb1963Eab30438024864c313F6/2430

The EIP155... Is not an imageURL. I'd prefer it came in the form of {https://...}. Is there any way to achieve this or convert the NFT URI EIP155... To an image or image URL.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As far as I know you will have to go through the entire process to get that IPFS URI.

You will want to take the contract address and token ID from that returned avatar string (the last 2 parts) and call the tokenURI ABI method, parse the JSON and read image there:

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contract = new ethers.Contract(address, abi, signer);

const uri = await contract.tokenURI(tokenId)
const data = (await axios.get(uri)).data;
const image = data.image;
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!