What are indexed parameters in blockchain event logs?
Indexed parameters are special event parameters that are stored in the blockchain's log topics, allowing efficient filtering and searching of events by these parameters.
Click to reveal answer
beginner
How many parameters can be indexed in a single event in Ethereum?
Up to three parameters can be indexed in a single event in Ethereum smart contracts.
Click to reveal answer
beginner
Why use indexed parameters in blockchain events?
Indexed parameters make it easier and faster to search for specific events by filtering logs based on these parameters without scanning all event data.
Click to reveal answer
intermediate
Show an example of an event declaration with indexed parameters in Solidity.
event Transfer(address indexed from, address indexed to, uint256 value);
Click to reveal answer
intermediate
What is the difference between indexed and non-indexed parameters in blockchain events?
Indexed parameters are stored in topics and can be filtered efficiently, while non-indexed parameters are stored in the event data and require full log scanning to access.
Click to reveal answer
How many parameters can you mark as indexed in an Ethereum event?
A1
B3
C5
DUnlimited
✗ Incorrect
Ethereum allows up to three parameters to be indexed in an event for efficient filtering.
What is the main benefit of using indexed parameters in blockchain events?
AIncreased contract storage
BLower gas cost for transactions
CAutomatic event execution
DFaster event filtering
✗ Incorrect
Indexed parameters allow faster filtering of events by storing key data in topics.
In Solidity, how do you mark a parameter as indexed in an event?
AAdd the keyword 'indexed' after the parameter type
BAdd the keyword 'filter' after the parameter
CUse a special event type
DIndexed parameters are not supported
✗ Incorrect
You add the keyword 'indexed' after the parameter type to mark it as indexed.
Which part of the event log stores indexed parameters?
ATopics
BData
CTransaction input
DBlock header
✗ Incorrect
Indexed parameters are stored in the topics section of the event log.
Can non-indexed parameters be used to filter events efficiently?
AOnly if the event is small
BYes, all parameters can be filtered equally
CNo, only indexed parameters can be filtered efficiently
DOnly if the blockchain is private
✗ Incorrect
Only indexed parameters are stored in topics and can be filtered efficiently.
Explain what indexed parameters are and why they are useful in blockchain event logs.
Think about how events are searched on the blockchain.
You got /4 concepts.
Describe how to declare an event with indexed parameters in Solidity and what happens when the event is emitted.
Recall Solidity syntax and event log structure.
You got /5 concepts.
Practice
(1/5)
1.
What is the main purpose of indexed parameters in blockchain events?
easy
A. To limit the size of event data
B. To encrypt event data for security
C. To tag event data for fast searching on the blockchain
D. To automatically execute functions on event trigger
Solution
Step 1: Understand the role of indexed parameters
Indexed parameters are used to tag event data so it can be searched quickly on the blockchain.
Step 2: Compare with other options
Encryption, size limits, or automatic execution are not related to indexed parameters.
Final Answer:
To tag event data for fast searching on the blockchain -> Option C
Quick Check:
Indexed parameters = fast search tags [OK]
Hint: Indexed means fast searchable tags in events [OK]
Common Mistakes:
Thinking indexed encrypts data
Confusing indexing with size limits
Assuming indexed triggers functions
2.
Which of the following is the correct syntax to declare an indexed parameter in a Solidity event?
event Transfer(address ? from, address to, uint amount);
easy
A. indexed
B. index
C. indexing
D. indexedParam
Solution
Step 1: Recall Solidity event syntax
The keyword to mark a parameter as indexed is exactly indexed.
Step 2: Check other options
Other words like index, indexing, or indexedParam are invalid in Solidity event declarations.
Final Answer:
indexed -> Option A
Quick Check:
Use 'indexed' keyword for parameters [OK]
Hint: Use exact keyword 'indexed' for event parameters [OK]
The event has four indexed parameters: from, amount, message, and timestamp.
Step 2: Recall indexing limit
Solidity allows a maximum of 3 indexed parameters per event. This declaration exceeds that limit.
Final Answer:
More than 3 parameters are indexed -> Option D
Quick Check:
4 indexed > max 3 [OK]
Hint: Max 3 indexed params per event [OK]
Common Mistakes:
Thinking 4 indexed parameters are allowed
Ignoring the 3 indexed parameter limit
Confusing event name rules
5.
You want to create an event to track token transfers with these details: sender address, receiver address, amount, and a note message. You want to filter events by sender and receiver. Which event declaration is correct?