Skip to content

Instantly share code, notes, and snippets.

@adietrichs
adietrichs / EIP3074Relayer.sol
Last active April 24, 2024 10:33
EIP-3074 Invoker Examples
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
interface WETH9 {
function balanceOf(address) external returns (uint256);
function deposit() external payable;
function withdraw(uint256) external;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AuthorizeProxy {
address public latestSigner;
function call(uint256 commit, uint256 v, uint256 r, uint256 s, uint256 _gas, address payable addr, bytes memory data) external payable {
address signer;
bool success;
@adietrichs
adietrichs / factors.py
Created October 23, 2021 00:17
Paradigm Pinball
from math import isqrt
nonprimes = set()
primes = [2]
prev_n = 2
def ensure_primes(n):
global prev_n
@adietrichs
adietrichs / hevm.md
Last active October 16, 2022 19:35
Dapptools Apple Silicon
@adietrichs
adietrichs / blocks.sql
Created December 10, 2021 00:19
EIP-4488 Optimal Mining Analysis
SELECT
t.number,
t.gas_limit,
t.base_fee_per_gas
FROM
`bigquery-public-data.crypto_ethereum.blocks` AS t
WHERE
t.timestamp >= "2021-11-30 00:00:00"
AND t.timestamp < "2021-12-07 00:00:00"
AND MOD(t.number, 10) = 1
@adietrichs
adietrichs / Car3.sol
Created August 22, 2022 00:57
0xMonaco 3rd Place Implementation
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "./Truck.sol";
contract Car3 is Truck {
// constants from Monaco
uint internal constant FINISH_DISTANCE = 1000;
constructor(Monaco _monaco) Truck(_monaco) {}
MODULUS_OPTIONS = [98304, 93600, 8191]
def slots_hit(modulus, starting_slot, slot_time):
assert 0 <= starting_slot < modulus
slots = [starting_slot]
while True:
next_slot = (slots[-1] + slot_time) % modulus
if next_slot == slots[0]:
break
slots.append(next_slot)