-
Notifications
You must be signed in to change notification settings - Fork 36
/
Video-11-Logs-and-Events.sol
42 lines (36 loc) · 1.01 KB
/
Video-11-Logs-and-Events.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
contract Log {
event SomeLog(uint256 indexed a, uint256 indexed b);
event SomeLogV2(uint256 indexed a, bool);
function emitLog() external {
emit SomeLog(5, 6);
}
function yulEmitLog() external {
assembly {
// keccak256("SomeLog(uint256,uint256)")
let
signature
:= 0xc200138117cf199dd335a2c6079a6e1be01e6592b6a76d4b5fc31b169df819cc
log3(0, 0, signature, 5, 6)
}
}
function v2EmitLog() external {
emit SomeLogV2(5, true);
}
function v2YulEmitLog() external {
assembly {
// keccak256("SomeLogV2(uint256,bool)")
let
signature
:= 0x113cea0e4d6903d772af04edb841b17a164bff0f0d88609aedd1c4ac9b0c15c2
mstore(0x00, 1)
log2(0, 0x20, signature, 5)
}
}
function boom() external {
assembly {
selfdestruct(caller())
}
}
}