starknet_getEvents

Returns all event objects matching the conditions in the provided filter

The StarkNet event mechanism allows a contract to output information during its execution that can later be used outside of StarkNet. For example, consider a token contract that allows transfers of tokens between users. By only querying StarkNet storage, a user can only see how much token they have, and not who transferred those tokens. An event, emitted by the contract whenever funds are transferred, can be used to allow the user to get this information.

Parameters

Object NameRequiredTypeDetail
fromBlockBlock Parameter"block_hash", "block_number", "latest", "pending"
toBlockBlock Parameter"block_hash", "block_number", "latest", "pending"
addressStringfrom contract address
chunk_sizeIntegerchunk size
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "starknet_getEvents",
    "params": [
        {
            "from_block": {
                "block_number": 51000
            },
            "to_block": {
                "block_number": 52000
            },
            "address": "0x07c5779f66fda05ce146747840f18760b1f81188415cb03847e6981e9b65da13",
            "chunk_size": 100
        }
    ]
}

Example

Request

curl <your-endpoint> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "starknet_getEvents",
    "params": [
        {
            "from_block": {
                "block_number": 51000
            },
            "to_block": {
                "block_number": 52000
            },
            "address": "0x07c5779f66fda05ce146747840f18760b1f81188415cb03847e6981e9b65da13",
            "chunk_size": 100
        }
    ]
}
'

Return

{
    "jsonrpc": "2.0",
    "result": {
        "events": [
            {
                "data": [
                    "0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570"
                ],
                "keys": [
                    "0x2db340e6c609371026731f47050d3976552c89b4fbb012941663841c59d1af3"
                ],
                "from_address": "0x7c5779f66fda05ce146747840f18760b1f81188415cb03847e6981e9b65da13",
                "block_hash": "0x627391f3feb38f137f310b30f3478d9b22ac6c60aa1e1eb9c3468ed3ec94d96",
                "block_number": 51487,
                "transaction_hash": "0x551f9b02e4823a9a95292aaa2b7f53a9100ddaa4e5b7ac01492dc17593b2b6f"
            },
            {
                "data": [
                    "0x1ab123347bb54806a1ca464db841897a72ace74de2fd43a21ca632cb78786f2"
                ],
                "keys": [
                    "0xd876503fb434f7517a7b4ae8d0d5fba27e2fa7b1a9f200deb935316f46fcc3"
                ],
                "from_address": "0x7c5779f66fda05ce146747840f18760b1f81188415cb03847e6981e9b65da13",
                "block_hash": "0x627391f3feb38f137f310b30f3478d9b22ac6c60aa1e1eb9c3468ed3ec94d96",
                "block_number": 51487,
                "transaction_hash": "0x551f9b02e4823a9a95292aaa2b7f53a9100ddaa4e5b7ac01492dc17593b2b6f"
            },
            {
                "data": [
                    "0x2c2b8f559e1221468140ad7b2352b1a5be32660d0bf1a3ae3a054a4ec5254e4"
                ],
                "keys": [
                    "0x2db340e6c609371026731f47050d3976552c89b4fbb012941663841c59d1af3"
                ],
                "from_address": "0x7c5779f66fda05ce146747840f18760b1f81188415cb03847e6981e9b65da13",
                "block_hash": "0x627391f3feb38f137f310b30f3478d9b22ac6c60aa1e1eb9c3468ed3ec94d96",
                "block_number": 51487,
                "transaction_hash": "0x551f9b02e4823a9a95292aaa2b7f53a9100ddaa4e5b7ac01492dc17593b2b6f"
            }
        ]
    },
    "id": 1
}
Language
Click Try It! to start a request and see the response here!