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

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

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 Relatório

0

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

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