Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda