Skip to content

Instantly share code, notes, and snippets.

@Shungy
Shungy / EIP138128.md
Last active December 26, 2023 22:21
EIP138128: Custom selector and encodings (Very early draft)

Using LEB128 encoding scheme for custom abi/interface.

ERC-138128: Custom function selector and calldata encoding scheme declaration standard

  • A contract SHOULD use ERC-165 standard to declare its support for ERC-138128 standard.
  • A contract supporting ERC-138128 MUST have these two view functions: customSelectors() and customEncodings().

customSelectors()

This function is used to declare alternative function selectors for any number of standard function signatures. This function MUST have the following interface.

@Shungy
Shungy / SumBytes.sol
Created October 11, 2023 10:06
For RareSkills gas optimization contest
pragma solidity 0.8.15;
contract SumBytes {
function sumBytes(bytes calldata input1, bytes calldata input2) public pure returns (bytes memory out) {
assembly ("memory-safe") {
let length := 0
let remainingLength := 0
out := mload(0x40)
switch gt(input2.length, input1.length)
@Shungy
Shungy / EvaConsole.huff
Created August 24, 2023 19:09
For Solving Curta Puzzle - Elohim
// Used to solve Puzzle 16 https://www.curta.wtf/puzzle/16 in God mode (aka chainlight mode).
#define constant EVA_CONFIG = 0x03306963 // ensure no restricted opcds here
#define macro MAIN() = takes (0) returns (0) {
0x00 calldataload 0xfc shr
dup1 0x0f eq eva_eight jumpi
dup1 0x08 eq eva_nine jumpi
0x06 eq eva_ten jumpi
@Shungy
Shungy / solve.py
Last active July 10, 2023 10:52
Curta Puzzle 13 Solution
import sys
import re
from starknet_py.hash.utils import pedersen_hash
from eth_utils import keccak, big_endian_to_int, to_checksum_address
# Change to at least ~10 hours after the current block due to L2->L1 Starknet transaction delay.
TARGET_BLOCK = 17666132
# Change to your Ethereum adress in decimal format.
MY_ADDRESS = 544888184176857984448844311794968001596801059536
@Shungy
Shungy / detector.py
Created June 3, 2023 16:57
slither detector
from slither.core.solidity_types.elementary_type import ElementaryType, Int, Uint
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import Assignment, Binary, BinaryType, Return, TypeConversion
from slither.slithir.variables import Constant
def _is_integer(variable):
return str(variable.type) in Uint + Int
def _get_variable_size(variable):
# Slither erroneously returns size 256 for all Uint and Int literals.
@Shungy
Shungy / Proxy.sol
Last active November 18, 2022 19:31
pragma solidity ^0.8.0;
// The Setup
// ---------
// Alice, Bob, and Mallory have a tea party
// Alice decided to give everyone tokens!
// Alice sets up a Proxy contract and a Token contract
// The tokens are shared between the three friends
// initialSupply is 30000000000000
// But are they truly friends? Or ex-friends?