-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Expand file tree
/
Copy pathabi_encode_empty_string_v1.sol
More file actions
34 lines (34 loc) · 1.45 KB
/
abi_encode_empty_string_v1.sol
File metadata and controls
34 lines (34 loc) · 1.45 KB
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
pragma abicoder v1;
contract C {
function f1() public returns (bytes memory) {
return abi.encode("");
}
function f2(string calldata msg) public returns (bytes memory) {
return abi.encode(msg);
}
function g1() public returns (bytes memory) {
return abi.encodePacked("");
}
function g2(string calldata msg) public returns (bytes memory) {
return abi.encodePacked(msg);
}
function h1() public returns (bytes memory) {
return abi.encodeWithSelector(0x00000001, "");
}
function h2(string calldata msg) public returns (bytes memory) {
return abi.encodeWithSelector(0x00000001, msg);
}
}
// ====
// ABIEncoderV1Only: true
// compileViaYul: false
// ----
// f1() -> 0x20, 0x40, 0x20, 0
// f2(string): 0x20, 0 -> 0x20, 0x40, 0x20, 0
// f2(string): 0x20, 0, 0 -> 0x20, 0x40, 0x20, 0
// g1() -> 32, 0
// g2(string): 0x20, 0 -> 0x20, 0
// g2(string): 0x20, 0, 0 -> 0x20, 0
// h1() -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0
// h2(string): 0x20, 0 -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0
// h2(string): 0x20, 0, 0 -> 0x20, 0x44, 26959946667150639794667015087019630673637144422540572481103610249216, 862718293348820473429344482784628181556388621521298319395315527974912, 0