Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda