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

61
Visualizações
Continuously listening to smart contract events

My NFT project architecture in such way that only when a minting event has occurred, a minted event is emitted and then I want to listen to that event so I trigger an upload of the JSON content that would be then visible to token owner (since anyone can potentially access the content of all the token by basically going to baseURI/tokenID and I want to keep the rarity of the tokens a secret until minted).

I want to create a function that continuously listens to new events from the minted event. I'm trying to access new events by using the following implementation, because I couldn't find an implementation that continuously listens to events from the contract.

async function listener() {
    events = nftContract.getPastEvents("minted",{fromBlock: 1}, function(err,res) {
        console.log(res);
    })

What is the best way to create a function that continues to poll events from the contract?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The full code of the solution is so:

const ethers = require('ethers');
const CONTRACT_ADDRESS = "0x10820dB......";
const ABIJSON = JSON.parse('{"_format": "hh-sol-artifact-1", "contractName": "testcontract", "....}')
provider = new ethers.providers.AlchemyProvider("ropsten");
const contract = new ethers.Contract(CONTRACT_ADDRESS, ABIJSON.abi, provider);

contract.on("eventName", ( caller,tokenID) => {
      //this section is called every time an event is emitted 
})
about 4 years ago · Juan Pablo Isaza 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