shazow / whatsabi

Extract the ABI (and resolve proxies, and get other metadata) from Ethereum bytecode, even without source code.
https://shazow.github.io/whatsabi/
MIT License
1.07k stars 76 forks source link

WIP: auto.AutoloadConfig.fallbackLoad #119

Open shazow opened 2 months ago

shazow commented 2 months ago

This was originally merged via #113 but after sleeping on it, it still feels underbaked so I reverted it and now re-opening here for progress tracking.

Feels like this might be better done by adding additional fallback loaders instead. Would be nice if we could verify that the bytecode matches, but we can do that with the getContract API.

Example:

 // USDT, available on both PulseChain and Mainnet (but only verified on mainnet)
const address = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
const result = await autoload(address, {
  provider: pulseChainProvider,
  fallbackLoad: {
    mainnnetProvider,
    ...whatsabi.loaders.defaultsWithEnv(env),
  }
});
console.log(result); // {isVerified: true, abi: [...], ...}