Skip to content

get value via event.args.EVENT_KEY in typescript does not work #766

@yurenju

Description

@yurenju

although it is undocumented but event.args actually can get event property via string instead of array, for example:

// solidity
event ValueChanged(address indexed author, string oldValue, string newValue);

function setValue(string value) public {
    emit ValueChanged(msg.sender, _value, value);
    _value = value;
}

// javascript
const tx = await contractWithSigner.setValue("I like turtles.");
const receipt = await tx.wait();
console.log(receipt.events[0].args.newValue)
// print "I like turtles."
console.log(receipt.events[0].args[2])
// same "I like turtles."

it works in javascript but does not work in typescript since args is defined as any[]:

export interface Event extends Log {
    args?: Array<any>;
   // ...
}

PR is on the way to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions