A small command-line utility to fetch contract ABIs from Etherscan's unified API and store them locally. This helps in managing ABIs for frequently interacted Ethereum contracts without having to keep track of individual files.
- Utilizes Etherscan's new unified API (v2) for fetching ABIs.
- Requires only one Etherscan API key for all supported chains.
- Organizes ABIs by
chainIdand checksummed contract address. - Stores ABIs in
~/.cache/abistash(or your system's equivalent cache directory).
- Node.js (LTS version recommended)
- npm (Node.js package manager)
npm install -g abistash-
Clone the repository:
git clone https://github.com/gearcat0/abistash cd abistash -
Install dependencies:
npm install
-
Link the executable (optional, but good for local development):
npm link
Before using abistash, you need to set your Etherscan API key as an environment variable.
You can obtain your single Etherscan API key from the Etherscan website. This key will work across all supported chains that use the Etherscan API v2.
export ETHERSCAN_API_KEY=yourkeyabistash [contract address] [optional chain ID or name, default is mainnet]
Fetch the ABI for USDT on Ethereum Mainnet:
abistash 0xdAC17F958D2ee523a2206206994597C13D831ec7 mainnetYou can also use the chain ID:
abistash 0xdAC17F958D2ee523a2206206994597C13D831ec7 1If the chain ID or name is omitted, it defaults to Mainnet (chain ID 1).
ABIs are stored in a structured directory under your user's cache directory:
~/.cache/abistash/
├── <chainId>/
│ └── <checksummed_address>.json
└── ...
For example, the ABI for USDT on Ethereum Mainnet would be saved as:
~/.cache/abistash/1/0xdAC17F958D2ee523a2206206994597C13D831ec7.json
- Mainnet (Chain ID 1)
- Ropsten (Chain ID 3)
- Kovan (Chain ID 42)
- Rinkeby (Chain ID 4)
- Goerli (Chain ID 5)
- Sepolia (Chain ID 11155111)
- Binance Smart Chain Mainnet (Chain ID 56)
- Binance Smart Chain Testnet (Chain ID 97)
- Polygon Mainnet (Chain ID 137)
- Polygon Amoy Testnet (Chain ID 80002)
- Arbitrum One (Chain ID 42161)
- Arbitrum Nova (Chain ID 42170)
- Optimism Mainnet (Chain ID 10)
- Optimism Sepolia (Chain ID 11155420)
- Fantom Opera (Chain ID 250)
- Avalanche C-Chain (Chain ID 43114)
- Cronos Mainnet (Chain ID 25)
Supported chains are fetched automatically from Etherscan, so abistash will support even more chains without code changes, as Etherscan provides the necessary API endpoints.
If you encounter issues with a supported network or need support for an additional one not listed (and confirmed by Etherscan to be on v2 API), please open an issue or contribute!
Contributions are welcome! Please feel free to submit a pull request or open an issue for bugs, feature requests, or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.