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

255
Views
Listen to Solidity Events using in Javascript using the UseDapp(React)

I am using the useDapp react Library to call a function on a Solidity using the useContractFunction.

 const { state, send, events } = useContractFunction(CreateERC20Contract, 'createToken', { transactionName: 'create a new erc20 token' })

I want to listen to events created by the smart contract in the React front-end using useDapp or any other library I can integrate with useDapp. I will be grateful if anyone has an Idea on how solidity contract events can be listened to using useDapp.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

UseDapp has a recent addition for this, a hook named useLogs.

I invite you to take a look and see if it works for your use case.

Example

This will download all Transfer events from an instance of a token contract, and print out transaction hash and data for every event.

const logs = useLogs(
  {
    contract: token,
    event: 'Transfer',
    args: [],
  },
  {
    fromBlock: 0,
    toBlock: 'latest',
  }
)

logs?.value?.forEach((log) => {
  console.log(log.transactionHash)
  console.log(log.data)
})

It's best to narrow down the amount of blocks you inspect using the fromBlock and toBlock parameters otherwise the query might get too big for the RPC provider. You can also use blockHash to target specific block.

about 4 years ago · Juan Pablo Isaza Report

0

The best way to listen to events is by using The Graph.

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!