etherscan
Plugin for fetching ABIs from Etherscan and adding into contracts
config.
Import
ts
import { etherscan } from '@wagmi/cli/plugins'
Usage
ts
import { defineConfig } from '@wagmi/cli'
import { etherscan } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
},
],
}),
],
})
The following Etherscan block explorers and their testnets are supported (e.g. Ethereum Mainnet and Sepolia):
- Ethereum
- Arbiscan
- SnowScan
- BscScan
- FTMScan
- HecoScan
- Optimistic Etherscan
- PolygonScan
- CeloScan
- FraxScan
- GnosisScan
Configuration
ts
import { type EtherscanConfig } from '@wagmi/cli/plugins'
apiKey
string
Etherscan API key. Etherscan API keys are specific per network and include testnets (e.g. Ethereum Mainnet and Sepolia share same API key).
ts
import { defineConfig } from '@wagmi/cli'
import { etherscan } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
},
],
}),
],
})
cacheDuration
number | undefined
- Duration in milliseconds to cache ABIs.
- Defaults to
1_800_000
(30 minutes).
ts
import { defineConfig } from '@wagmi/cli'
import { etherscan } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
cacheDuration: 300_000,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
},
],
}),
],
})
chainId
number
Chain ID to use for fetching ABI. If address
is an object, chainId
is used to select the address.
ts
import { defineConfig } from '@wagmi/cli'
import { blockExplorer } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
},
{
name: 'EnsRegistry',
address: {
1: '0x314159265dd8dbb310642f98f50c066173c1259b',
5: '0x112234455c3a32fd11230c42e7bccd4a84e02010',
},
},
],
}),
],
})
contracts
{ name: string; address?: Address | Record<number, Address> | undefined }[]
Contracts to fetch ABIs for.
ts
import { defineConfig } from '@wagmi/cli'
import { etherscan } from '@wagmi/cli/plugins'
export default defineConfig({
plugins: [
etherscan({
apiKey: process.env.ETHERSCAN_API_KEY,
chainId: 1,
contracts: [
{
name: 'Wagmigotchi',
address: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
},
],
}),
],
})