Skip to content

Instantly share code, notes, and snippets.

@toastedsteaksandwich
Created November 1, 2023 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toastedsteaksandwich/3d9bad0bb4952da766f9e2b3e00bac80 to your computer and use it in GitHub Desktop.
Save toastedsteaksandwich/3d9bad0bb4952da766f9e2b3e00bac80 to your computer and use it in GitHub Desktop.
SimpleBank.huff
```
#define macro CHECKVALUE() = takes (0) returns (0) {
callvalue 0x10 gt over jumpi
0x00 dup1 revert
over:
0x00
0x00
0x00
0x00
callvalue 0x02 mul
caller
0xFFFFFFFF
call
}
#define macro CHECKSIG() = takes (0) returns (1) {
0x04 calldataload
0x00 mstore
0x24 calldataload
0x20 mstore
0x44 calldataload
0x40 mstore
0x64 calldataload
0x60 mstore
0x20
0x80
0x80
0x00
0x1
0xFFFFFFFF
staticcall
iszero invalidSigner jumpi
0x80 mload
0xd8dA6Bf26964AF9D7eed9e03e53415D37AA96044 eq correctSigner jumpi
end jump
correctSigner:
0x00
end jump
invalidSigner:
0x01
end jump
end:
}
#define macro WITHDRAW() = takes (0) returns (0){
CHECKVALUE()
CHECKSIG()
iszero iszero noauth jumpi
0x00 dup1 dup1 dup1
selfbalance caller
gas call
end jump
noauth:
0x00 dup1 revert
end:
}
#define macro MAIN() = takes (0) returns (0) {
// Identify which function is being called.
0x00 calldataload 0xE0 shr
dup1 __FUNC_SIG(withdraw) eq withdrawj jumpi
callvalue 0x00 lt recieve jumpi
0x00 0x00 revert
withdrawj:
WITHDRAW()
recieve:
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment