-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calyptus448.sol
28 lines (22 loc) · 931 Bytes
/
Calyptus448.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
// https://x.com/calyptus_web3/status/1843169406228033550
/*
Do you know what is the difference between an indexed and an unindexed parameter in an event,
as shown in the picture? Tell us in the comments. Also tell us if one costs more gas than the other.
*/
contract MyContract{
// Define an event with indexed and non-indexed parameters
event ItemSetIndexed(bytes32 indexed key, uint256 value);
event ItemSetUnindexed(bytes32 key, uint256 value);
mapping (bytes32 => uint256) public items;
bytes32 public data = keccak256("Hello, World!");
function setItemIndexed(bytes32 key, uint256 value) public {
items[key] = value;
emit ItemSetIndexed(key, value); // Trigger the event
}
function setItemUnindexed(bytes32 key, uint256 value) public {
items[key] = value;
emit ItemSetUnindexed(key, value);
}
}