DocumentationBlog

apibara.model

Classes used in the Python SDK.

EventFilter#

class EventFilter:
"""Filter transactions events based on their signature.
The EventFilter can, optionally, filter by the emitting contract.
Parameters
----------
signature:
the event signature.
address:
the contract address.
"""
signature: str
address: Optional[bytes]
@classmethod
def from_event_name(
cls, name: str, address: Optional[Union[str, bytes, int]] = None
) -> "EventFilter":
"""Create an EventFilter from the event name and contract address."""
def to_json(self):
"""Returns the json representation of the filter."""
@classmethod
def from_json(cls, data):
"""Create an EventFilter from its json representation."""

BlockHeader#

class BlockHeader:
"""Information about a block.
Parameters
----------
hash:
the block hash.
parent_hash:
the hash of the block's parent.
number:
the block number.
timestamp:
the block timestamp.
"""
hash: bytes
parent_hash: Optional[bytes]
number: int
timestamp: datetime

Event#

class Event:
"""Base class for chain-specific events."""

StarkNetEvent#

class StarkNetEvent(Event):
"""StarkNet event.
Parameters
----------
name:
event name.
address:
address of the contract emitting the event.
log_index:
index in the list of events emitted by the block.
topics:
event topics. Usually this is the hash of the event name.
data:
raw event data.
transaction_hash:
hash of the transaction emitting the event.
"""
name: Optional[str]
address: bytes
log_index: int
topics: List[bytes]
data: List[bytes]
transaction_hash: bytes

NewBlock#

class NewBlock:
"""Information about a new block being indexed.
Parameters
----------
new_head:
block header.
"""
new_head: BlockHeader

NewEvents#

class NewEvents:
"""Information about indexed events in a block.
Parameters
----------
block
the block containing the events.
events:
list of events.
"""
block: BlockHeader
events: List[Event]