Skip to content

Improvements for *ContractEvent and *ContractFunction APIs #3556

Closed
@fselmo

Description

@fselmo

What feature should we add?

I see some low-hanging fruit in contract interactions with functions and events.

  • contract.myFunction.signature & contract.MyEvent.signature

    • We could use a clearer attribute to signify signature. Right now this is the same thing as abi_element_identifier, though I'm not sure off the top of my head if this always returns the signature.
  • contract.MyEvent.to_topic() (.as_topic(), .topic?)

    • We could use an API that returns the event as a topic (w3.keccak(text=event_signature).to_0x_hex()). This would significantly improve subscribing to topics on contracts:
    w3.eth.subscribe(
        "logs", 
        {
            "address": my_contract.address,
            "topics": [
                my_contract.events.MyEvent.to_topic()
            ]
        }
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions