Skip to content

fix(cli/foundry): support multiple addresses sharing same ABI via DisplayName:ArtifactName#5131

Open
0xAxiom wants to merge 2 commits into
wevm:mainfrom
0xAxiom:fix/foundry-multi-address-same-abi
Open

fix(cli/foundry): support multiple addresses sharing same ABI via DisplayName:ArtifactName#5131
0xAxiom wants to merge 2 commits into
wevm:mainfrom
0xAxiom:fix/foundry-multi-address-same-abi

Conversation

@0xAxiom
Copy link
Copy Markdown

@0xAxiom 0xAxiom commented May 21, 2026

Closes #4396.

Problem

When multiple tokens share an ABI (e.g. DAI and WETH both use ERC20.json), the deployments map previously only accepted one entry per contract name — later entries silently overwrote earlier ones, producing only one export instead of two.

Solution

Add a 'DisplayName:ArtifactName' key syntax to the foundry plugin's deployments option. Any key ending in :ArtifactName is treated as an alias: the ABI is read from ArtifactName.json and the generated export uses DisplayName as its name. Multiple aliases for the same artifact each produce their own named contract config.

// wagmi.config.ts
export default defineConfig({
  plugins: [
    foundry({
      deployments: {
        'DAI:ERC20':  { 1: '0x6B175474E89094C44Da98b954EedeAC495271d0F' },
        'WETH:ERC20': { 1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' },
      },
    }),
  ],
})

Generated output:

export const daiAddress = { 1: '0x6B175...' } as const
export const daiConfig = { address: daiAddress, abi: erc20Abi } as const

export const wethAddress = { 1: '0xC02aA...' } as const
export const wethConfig = { address: wethAddress, abi: erc20Abi } as const

Behaviour

Key format Behaviour
'ERC20' Unchanged — direct match, one contract, name = ERC20
'DAI:ERC20' Alias — ABI from ERC20.json, name = DAI
'DAI:ERC20' + 'WETH:ERC20' Two contracts (DAI, WETH), both with erc20Abi

Changes

  • packages/cli/src/plugins/foundry.tsgetDeploymentsForArtifact helper + updated contracts() loop + JSDoc on deployments option
  • packages/cli/src/plugins/foundry.test.ts — two new tests: multi-alias and single-alias cases

…playName:ArtifactName

Closes wevm#4396.

When multiple tokens share an ABI (e.g. DAI and WETH both use ERC20),
the `deployments` map previously only accepted one entry per contract name,
causing later entries to silently overwrite earlier ones.

Add `'DisplayName:ArtifactName'` key syntax to the foundry plugin's
`deployments` option. Any key ending in `:ArtifactName` is treated as an
alias: the ABI is read from `ArtifactName.json` and the generated export
uses `DisplayName` as its name. Multiple aliases for the same artifact each
produce their own named contract config.

```ts
// wagmi.config.ts
deployments: {
  'DAI:ERC20':  { 1: '0x6B175...' },
  'WETH:ERC20': { 1: '0xC02aA...' },
}
// generates: daiConfig + wethConfig, both with erc20Abi
```

Direct-key deployments (`{ ERC20: { ... } }`) continue to work unchanged.
Tests added for multi-alias, single-alias, and direct-key cases.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

@0xAxiom is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: f903c2c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: foundry plugin multiple addresses referencing the same ABI

1 participant