import { Function } from 'tevm'
const functions = [
new Function({
type: "function",
name: "transfer",
inputs: [
{ type: "address", name: "to" },
{ type: "uint256", name: "amount" }
]
}),
new Function({
type: "function",
name: "approve",
inputs: [
{ type: "address", name: "spender" },
{ type: "uint256", name: "amount" }
]
}),
new Function({
type: "function",
name: "balanceOf",
inputs: [{ type: "address", name: "owner" }]
})
]
// Create selector → function mapping
const registry = new Map(
functions.map(fn => [fn.getSelector(), fn])
)
// Look up function by selector
const selector = "0xa9059cbb"
const fn = registry.get(selector)
console.log(fn?.name) // "transfer"