Skip to content

Instantly share code, notes, and snippets.

View ItsCuzzo's full-sized avatar
🎯
Focusing

Alan ItsCuzzo

🎯
Focusing
View GitHub Profile
@ItsCuzzo
ItsCuzzo / AsmArrays.sol
Last active September 14, 2022 14:11
Understanding arrays using assembly.
contract AsmArray {
uint256[] public arr;
/// @dev Push some dummy data to begin with.
constructor() {
arr.push(1);
arr.push(2);
}
/// @dev Function used to view the value of `arr[idx]`.
@ItsCuzzo
ItsCuzzo / AsmMappings.sol
Last active August 9, 2022 15:07
Understanding mappings in Solidity using assembly.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;
contract AsmMapping {
mapping(uint256 => uint256) private _map;
/// @dev Set some dummy data to begin with.
constructor() {
_map[0] = 2;
@ItsCuzzo
ItsCuzzo / Counters.sol
Last active August 6, 2022 13:23
Implementation of OZ Counters in assembly.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.15;
library Counters {
error IntegerUnderflow();
struct Counter {
uint256 value;
}
@ItsCuzzo
ItsCuzzo / KekTest.sol
Created August 9, 2022 07:13
Testing keccak in assembly.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
contract KekTest {
/// 22578
function regHash(uint256 a, uint256 b) external pure returns (bytes32) {
return keccak256(abi.encodePacked(a, b));
}
@ItsCuzzo
ItsCuzzo / CityAsm.sol
Created September 22, 2022 08:33
The core functionality from my "Optimising Gamified 2D Grid Movement" series on Medium.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
import { ICity } from "./interfaces/ICity.sol";
/// @title Inspired by the Hobo Wars daily event of city exploration.
/// @author ItsCuzzo
/// @dev Source: https://wiki.hobowars.com/index.php?title=Exploring
/// Memory layout per invoke, assumes the transaction succeeds. Numbers provided
@ItsCuzzo
ItsCuzzo / disassembler.py
Created December 24, 2022 06:08
EVM Bytecode Disassembler
opcodes = {
0x00: 'STOP',
0x01: 'ADD',
0x02: 'MUL',
0x03: 'SUB',
0x04: 'DIV',
0x05: 'SDIV',
0x06: 'MOD',
0x07: 'SMOD',
0x08: 'ADDMOD',