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

252
Vistas
How to get Transaction Receipt Event Logs?

I need to get the events emitted by my smart contract and consume them in the front end via web3.

I made some event on my contract that returns event winner and ticket number:

event Winner(uint256 ticketNumber, address winner);

So I emit this event, and I see it on transaction logs.

From Etherscan:

enter image description here

OK! What I need is the data: ticketNumber: 1, winner: 0x........ How did I get this from web3?

Im trying to use:

 await web3.eth.getTransactionReceipt(txnHash, function (error, result) {
          console.log(result);
        });

But when I check console log, I cannot see this information, I suspect that result.logs.data is the right info, but I don't know for sure, and I don't know how to translate:

"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000005964b608ea267bfe9ef77707fce8105a2d145e7a"

Anybody have an idea?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you read the docs, there is getPastEvents method.

myContract.getPastEvents('MyEvent', {
    filter: {myIndexedParam: [20,23], myOtherIndexedParam: '0x123456789...'}, // Using an array means OR: e.g. 20 or 23
    fromBlock: 0,
    toBlock: 'latest'
}, function(error, events){ console.log(events); })
.then(function(events){
    console.log(events) // same results as the optional callback above
});

you can also create event listeners:

contract.events.Winner()
.on('data', (event) => {
    console.log(event);
})
.on('error', console.error);

Docs about subscription to events

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