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

150
Vistas
Get events from a transaction receipt in hardhat

I have an ethers contract that I've made a transaction with:

const randomSVG = new ethers.Contract(RandomSVG.address, RandomSVGContract.interface, signer)
let tx = await randomSVG.create()

I have an event with this transaction:

function create() public returns (bytes32 requestId) {
        requestId = requestRandomness(keyHash, fee);
        emit requestedRandomSVG(requestId);
    }

However, I can't see the logs in the transaction receipt.](https://docs.ethers.io/v5/api/providers/types/#providers-TransactionReceipt)

// This returns undefined
console.log(tx.logs)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When you create a transaction with Ethers.js, you get back a TransactionResponse that may not be included in the blockchain yet. Therefore it doesn't know what logs will be emitted.

Instead, you want to wait until the transaction is confirmed and you get back a TransactionReceipt. At this point the transaction was included in a block, and you can see which events were emitted.

const randomSVG = new ethers.Contract(RandomSVG.address, RandomSVGContract.interface, signer)
const tx = await randomSVG.create()
// Wait until the tx has been confirmed (default is 1 confirmation)
const receipt = await tx.wait()
// Receipt should now contain the logs
console.log(receipt.logs)
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