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

55
Views
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 answers
Answer question

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 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!