Last active
June 10, 2023 17:01
-
-
Save devtooligan/88500ec4af0558edb4f475138602e6cf to your computer and use it in GitHub Desktop.
Returning a string in Huff, the "Seaport" way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Goal: | |
0x00: 0000000000000000000000000000000000000000000000000000000000000020 (offset) | |
0x20: 0000000000000000000000000000000000000000000000000000000000000003 (length) | |
0x40: 544b4e0000000000000000000000000000000000000000000000000000000000 (“TKN”) | |
Normal way: | |
Step 1) | |
0x20 0x00 MSTORE | |
Memory layout: | |
0000000000000000000000000000000000000000000000000000000000000020000000000000000000 | |
0000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
0000000000000000000000000000 | |
Step 2) | |
0x3 0x20 MSTORE | |
0000000000000000000000000000000000000000000000000000000000000020000000000000000000 | |
0000000000000000000000000000000000000000000003000000000000000000000000000000000000 | |
0000000000000000000000000000 | |
Step 3) | |
0x544b4e0000000000000000000000000000000000000000000000000000000000 0x40 MSTORE | |
0000000000000000000000000000000000000000000000000000000000000020000000000000000000 | |
0000000000000000000000000000000000000000000003544b4e000000000000000000000000000000 | |
0000000000000000000000000000 | |
“Seaport” way: | |
Step 1) | |
0x20 0x00 MSTORE | |
Memory layout: | |
0000000000000000000000000000000000000000000000000000000000000020000000000000000000 | |
0000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
0000000000000000000000000000 | |
Step 2) | |
0x3544b4e 0x23 MSTORE | |
0000000000000000000000000000000000000000000000000000000000000020000000000000000000 | |
0000000000000000000000000000000000000000000003544b4e000000000000000000000000000000 | |
0000000000000000000000000000 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment