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

143
Views
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 answers
Answer question

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 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!