43 lines
1.7 KiB
Markdown
43 lines
1.7 KiB
Markdown
# Plugins
|
|
|
|
Plugins for managing ABIs, generating code, and more.
|
|
|
|
## Import
|
|
|
|
Import via the `'@wagmi/cli/plugins'` entrypoint.
|
|
|
|
```ts
|
|
import { etherscan } from '@wagmi/cli/plugins'
|
|
```
|
|
|
|
## Available Plugins
|
|
|
|
- [`actions`](/cli/api/plugins/actions) Generate type-safe VanillaJS actions from configuration `contracts`.
|
|
- [`blockExplorer`](/cli/api/plugins/blockExplorer) Fetch ABIs from Block Explorers that support `?module=contract&action=getabi`.
|
|
- [`etherscan`](/cli/api/plugins/etherscan) Fetch ABIs from Etherscan and add into configuration.
|
|
- [`fetch`](/cli/api/plugins/fetch) Fetch and parse ABIs from network resource with `fetch`.
|
|
- [`foundry`](/cli/api/plugins/foundry) Generate ABIs and watch for Foundry project changes.
|
|
- [`hardhat`](/cli/api/plugins/hardhat) Generate ABIs and watch for Hardhat projects changes.
|
|
- [`react`](/cli/api/plugins/react) Generate type-safe React Hooks from configuration `contracts`.
|
|
- [`sourcify`](/cli/api/plugins/sourcify) Fetch ABIs from Sourcify from configuration `contracts`.
|
|
|
|
## Create Plugin
|
|
|
|
Creating plugins to hook into the CLI is quite simple. Plugins most commonly inject contracts into `contracts` config, e.g. [`etherscan`](/cli/api/plugins/etherscan), and/or generate code using the `run` option, e.g. [`react`](/cli/api/plugins/react). All you need to do is write a function that returns the `Plugin` type.
|
|
|
|
```ts{3-8}
|
|
import { type Plugin, defineConfig } from '@wagmi/cli'
|
|
|
|
function myPlugin(): Plugin {
|
|
// `name` is the only required property.
|
|
name: 'MyPlugin',
|
|
// You likely want to at least include `contracts` or `run`.
|
|
// ...
|
|
}
|
|
|
|
export default defineConfig({
|
|
out: 'src/generated.ts',
|
|
plugins: [myPlugin()],
|
|
})
|
|
```
|