Filtering events with #keys didn't work using StarkNet

31 views Asked by At

I'm trying to filter the events emmited by my contract 0x028a88bc21629b0f740b99046dbd096674e4cf89545efa6a6cd20b3e64ebb94c which is in starknet goreli (link).

Now when I'm trying to filter the events with the indexed fields it's giving me all the events with that event name i.e it's not filtering with the indexed fields (keys) like its supposed to.

So, the event, which looks like this in cairo.

#[derive(Drop, starknet::Event)]
    struct ERC1155CollectionLaunch {
        #[key]
        tokenId: felt252,
        #[key]
        creator: ContractAddress,
        initialSupply: felt252
    }

When I’m filtering through the events from my RPC node with starknet_getEvents like this:

const keyFilter = [num.toHex(hash.starknetKeccak('ERC1155CollectionLaunch')), num.toHex("3"), "0x2dc934022ca93a0465a08bde434d979bac60fc3fcb07cf4d0b8d5c0af8cf442"];

        const options = {
          method: 'POST',
          headers: {accept: 'application/json', 'content-type': 'application/json'},
          body: JSON.stringify({
            id: 1,
            jsonrpc: '2.0',
            method: 'starknet_getEvents',
            params: [
              {
                to_block: 'latest',
                address: '0x028a88bc21629b0f740b99046dbd096674e4cf89545efa6a6cd20b3e64ebb94c',
                chunk_size: 10,
                keys: [keyFilter]
              },
            ]
          })
        };

Now this only filters the events based on the EVENT_NAME, the keys in this case: (tokenId, creator) altho I’m passing to the keys parameter, they’re not being used for filtration. In the end I’m getting all the events with the event name/type ERC1155CollectionLaunch.

0

There are 0 answers