Challenge - 5 Problems
Indexed Parameters Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of event with indexed parameters
Consider the following Solidity event and transaction. What will be the output when the event is emitted and filtered by the indexed parameter?
Blockchain / Solidity
pragma solidity ^0.8.0; contract Test { event Transfer(address indexed from, address indexed to, uint amount); function send(address to, uint amount) public { emit Transfer(msg.sender, to, amount); } }
Attempts:
2 left
💡 Hint
Indexed parameters appear as topics in event logs.
✗ Incorrect
In Solidity, parameters marked as 'indexed' in events are stored as topics in the event logs, allowing efficient filtering. Non-indexed parameters are stored in the data section.
❓ Predict Output
intermediate1:30remaining
Number of topics in event logs
Given this Solidity event, how many topics will be present in the event log when emitted?
Blockchain / Solidity
event Approval(address indexed owner, address indexed spender, uint256 value);
Attempts:
2 left
💡 Hint
Each indexed parameter adds one topic, plus the event signature topic.
✗ Incorrect
Event logs always have the event signature as the first topic. Each indexed parameter adds one additional topic.
🔧 Debug
advanced2:30remaining
Why does filtering by a non-indexed parameter fail?
A developer tries to filter events by a non-indexed parameter but gets no results. Why does this happen?
Blockchain / Solidity
event Deposit(address indexed user, uint amount); // Filtering by amount filter = {amount: 100};
Attempts:
2 left
💡 Hint
Filtering by indexed parameters uses topics, non-indexed parameters are in data and not filterable.
✗ Incorrect
Ethereum nodes can only filter events by topics, which correspond to indexed parameters. Non-indexed parameters are stored in data and require manual filtering after retrieval.
📝 Syntax
advanced1:30remaining
Identify the syntax error in event declaration
Which option contains a syntax error in declaring an event with indexed parameters?
Attempts:
2 left
💡 Hint
The 'indexed' keyword must come immediately after the type.
✗ Incorrect
In Solidity, the 'indexed' keyword must appear immediately after the parameter type. Option A places 'indexed' after the parameter name, which is invalid syntax.
🚀 Application
expert3:00remaining
Max number of indexed parameters in an event
What is the maximum number of indexed parameters allowed in a Solidity event, and why?
Attempts:
2 left
💡 Hint
The event signature occupies one topic, and the total topics per log is limited.
✗ Incorrect
Ethereum event logs can have up to 4 topics: one for the event signature and up to 3 for indexed parameters. This is a protocol limit.