Skip to content

Instantly share code, notes, and snippets.

View bkpleb's full-sized avatar
focusing

Bithiah K. bkpleb

focusing
View GitHub Profile
@bkpleb
bkpleb / decodeERC7579.ts
Created July 26, 2025 16:47
decode ZeroDev/ERC7579 calldata
import { decodeFunctionData, hexToBytes, parseAbi, decodeAbiParameters } from "viem";
export interface Execution {
target: string;
value: bigint;
callData: `0x${string}`;
}
/**
* Decodes a `bytes` blob containing an ABI‐encoded
@bkpleb
bkpleb / decodeAlchemy.ts
Created July 26, 2025 16:38
decode Alchemy calldata
import { parseAbi, decodeFunctionData } from "viem";
export interface Execution {
target: string;
value: bigint;
callData: `0x${string}`;
}
// ABI covering all four entry-points
const accountAbi = parseAbi([
@bkpleb
bkpleb / calculateSelector.ts
Created July 26, 2025 13:48
A function selector calculator that helps identify different Account Abstraction (AA) implementations by their unique function signatures.
// calculate_function_selector.js
import { keccak256, toUtf8Bytes } from 'ethers';
function calculateFunctionSelector(functionSignature: string): string {
const fullHash = keccak256(toUtf8Bytes(functionSignature));
const selector = fullHash.slice(0, 10); // First 4 bytes (8 hex chars + '0x')
console.log('Function signature:', functionSignature);
console.log('Full Keccak256 hash:', fullHash);
console.log('Function selector (first 4 bytes):', selector);