1

I am running the propose.ts to execute the propose function from Governor contract the args are transacted on the local blockchain as I retrieved the logs from the transaction event.

EventLog {
    fragment: EventFragment {
      type: 'event',
      inputs: [Array],
      name: 'ProposalCreated',
      anonymous: false
    },
    args: Result(9) [
      71868859171677419052155345699497483540960066113331982602962523540651890624828n,
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      [Result],
      [Result],
      [Result],
      [Result],
      16n,
      21n,
      'This proposal shall execute the box store function to save the uint256 passed through proposal'
    ]
  }
]

Here's the code according to the tutorial video though I am using ethers v6. proposeReceipt.events[0].args.proposalId returns error

TypeError: Cannot read properties of undefined (reading '0')

const proposeTx = await governor.getFunction("propose")(
    [await box.getAddress()],
    [0],
    [encodedFunctionCall],
    proposalDescription
  )
  // If working on a development chain, we will push forward till we get to the voting period.
  if (developmentChains.includes(network.name)) {
    await moveBlocks(VOTING_DELAY + 1)
  }

  const proposeReceipt = await proposeTx.wait(1);
  const proposalId = proposeReceipt.events[0].args.proposalId
  console.log(`Proposed with proposal ID:\n  ${proposalId}`)

1 Answer 1

1

The receipt has the events listed under the logs key and not events. This should work:

const log = governor.interface.parseLog(proposeReceipt.logs[0]);
const proposalId = log.args.proposalId;
1
  • Didn't reckon pareLog method. Thank you :) Aug 14 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.