Skip to content

Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0#747

Merged
ericglau merged 38 commits intoOpenZeppelin:masterfrom
ericglau:erc20crosschain
Feb 25, 2026
Merged

Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0#747
ericglau merged 38 commits intoOpenZeppelin:masterfrom
ericglau:erc20crosschain

Conversation

@ericglau
Copy link
Member

@ericglau ericglau commented Dec 1, 2025

Overview

In Solidity ERC-20's Cross-Chain Bridging section, adds an ERC-7866 Native option to use ERC20Crosschain. When this is selected, it also shows a sub-option Allow Link Overrides which defaults to false.

Both the ERC-7866 Native (ERC20Crosschain) and Custom (ERC20Bridgeable) bridging options will require access control.

ERC-7866 Native requires OpenZeppelin Contracts 5.6.0.

Breaking Changes

Custom bridging option now requires access control to allow privileged roles to update the token bridge address after deployment.

Rationale: Tokens may want to update their bridge address to use a BridgeERC7802, which requires the token address as a constructor argument to set an immutable variable. This implies the token must be deployed before the bridge.

New Features

ERC-7786 Native (ERC20Crosschain) embeds an ERC-7786 based bridge directly in the token contract. This option requires access control to manage crosschain links.

  • Allow Link Overrides: When enabled, privileged roles can replace previously registered crosschain links. Defaults to false.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

This PR adds support for ERC-7786 native cross-chain bridging option across OpenZeppelin Wizard for ERC20, stablecoin, and Real World Asset contracts. It introduces a new crossChainLinkAllowOverride option, updates access control requirements to include the new bridging type, adds tokenBridge state management with setter functions, updates UI controls, and expands test coverage. It also updates build configuration to enable IR-based compilation and switches OpenZeppelin contracts dependency to the master branch.

Changes

Cohort / File(s) Summary
Changesets
\.changeset/ninety-ears-slide\.md, \.changeset/sad-cases-yawn\.md
Documents patch version bump and breaking/feature changes: ERC-7786 native bridging support, custom bridging now requires access control, new updateTokenBridgeAddress() function, and constructor parameter reordering.
Descriptions & Schemas
packages/common/src/ai/descriptions/solidity\.ts, packages/mcp/src/solidity/schemas\.ts, packages/ui/api/ai-assistant/function-definitions/solidity\.ts
Updated ERC20 descriptions to document ERC-7786 native option, added crossChainLinkAllowOverride field to schemas, and expanded crossChainBridging option set to include 'erc7786native'.
Core ERC20 Logic
packages/core/solidity/src/erc20\.ts
Extended cross-chain bridging options to include 'erc7786native', added crossChainLinkAllowOverride option flag, updated isAccessControlRequired logic, introduced addERC20Crosschain pathway, and enriched custom bridging with tokenBridge state management and setter functions.
ERC20 Generation & Stablecoin Logic
packages/core/solidity/src/generate/erc20\.ts, packages/core/solidity/src/generate/stablecoin\.ts, packages/core/solidity/src/stablecoin\.ts
Added crossChainLinkAllowOverride to ERC20 and stablecoin option generators with appropriate defaults, and refactored isAccessControlRequired to delegate to ERC20's implementation.
Build Configuration
packages/core/solidity/hardhat\.config\.js, packages/core/solidity/package\.json, packages/core/solidity/remappings\.txt, packages/core/solidity/src/environments/hardhat/(package\.json|upgradeable/package\.json), packages/uniswap-hooks/remappings\.txt
Added viaIR: true to hardhat optimizer settings, updated @openzeppelin/contracts dependency from ^5.5.0 to git master branch across multiple locations, and updated remappings to include @openzeppelin/contracts/contracts/ path.
Test Snapshots
packages/core/solidity/src/erc20\.test\.ts\.md, packages/core/solidity/src/zip-foundry\.test\.ts\.md
Updated contract inheritance order to include OwnableUpgradeable, added setTokenBridge() setter function with onlyOwner guard, adjusted constructor/initializer signatures to accept initialOwner, and modified parameter ordering in initialization sequences.
ERC20 Tests
packages/core/solidity/src/erc20\.test\.ts
Added test cases for ERC-7786 native bridging variants with combinations including allowOverride, ownable, roles, managed, and upgradeable patterns.
UI Controls
packages/ui/src/solidity/ERC20Controls\.svelte, packages/ui/src/solidity/StablecoinControls\.svelte, packages/ui/src/solidity/RealWorldAssetControls\.svelte
Added conditional showAllowOverride reactive flag, introduced "ERC-7786 Native" radio option under Cross-Chain Bridging, and conditionally renders "Allow Link Overrides" checkbox when ERC-7786 native is selected.
MCP Tools & Tests
packages/mcp/src/solidity/tools/(erc20|stablecoin|rwa)\.(ts|test\.ts)
Added crossChainLinkAllowOverride parameter to tool handlers and propagated into options objects; added corresponding test cases validating the new option combinations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Key areas requiring close attention:
    • Core logic changes in packages/core/solidity/src/erc20.ts: new addERC20Crosschain bridging pathway, updated addCustomBridging with storage-based tokenBridge management, and access control logic updates.
    • Snapshot updates with inheritance reordering and parameter sequence changes in erc20.test.ts.md and zip-foundry.test.ts.md — verify no behavioral regressions and that test assertions align with new public signatures.
    • OpenZeppelin contracts dependency change from semver ^5.5.0 to git master branch — assess implications for reproducibility and stability across build environments.
    • Test coverage: verify new ERC-7786 native test cases exercise all combinations (allowOverride, access control, upgradeable variants) and that existing tests remain unbroken.

Possibly related PRs

  • Add Polkadot Solidity tab #650: Related through overlapping UI/code-generation surface modifications — both update ERC20/Stablecoin/RWA control files and function definitions to introduce or refine cross-chain bridging feature conditioning (superchain/erc7786native variants and option propagation patterns).
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: adding an ERC-7786 based crosschain bridge option for ERC-20 and updating to use Contracts 5.6.0 (via master branch).
Description check ✅ Passed The PR description clearly explains the addition of ERC-7786 Native bridging option, breaking changes to custom bridging requiring access control, and the Allow Link Overrides feature, all of which are reflected in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link

socket-security bot commented Dec 1, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • ansi-styles@6.2.3
  • @fhevm/host-contracts@0.9.0
  • @fhevm/solidity@0.9.1
  • @fhevm/mock-utils@0.3.0-1
  • @fhevm/hardhat-plugin@0.3.0-1

View full report

args: [
{ name: 'gateway', type: 'address' },
{ name: 'counterpart', type: 'bytes memory' },
{ name: 'allowOverride', type: 'bool' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be an argument in the public function. The contract has to hardcode a value IIUC. CC @Amxx

Copy link
Contributor

@frangio frangio Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From @Amxx: allowOverride should be false by default so that links are immutable once set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also consider adding a comment explaining the choice of false and when to consider changing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an option for this with default as false.

@frangio
Copy link
Contributor

frangio commented Dec 4, 2025

I think "ERC-7786 Native" instead of "Embedded" is a clearer and more compelling name.

Open to other suggestions involving ERC-7786.

@socket-security
Copy link

socket-security bot commented Dec 4, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​fhevm/​solidity@​0.9.1561005688100
Added@​fhevm/​hardhat-plugin@​0.3.0-18010010093100

View full report

@ericglau ericglau requested a review from frangio December 4, 2025 23:20
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
contract MyToken is ERC20, ERC20Bridgeable, ERC20Permit {␊
contract MyToken is ERC20, ERC20Bridgeable, Ownable, ERC20Permit {␊
Copy link
Contributor

@Amxx Amxx Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would it take to join the ERC20XXX inheritance and have Ownable at the end. Not really an issue, but it would be cleaner if we could achieve that easily

Copy link
Member Author

@ericglau ericglau Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to do this but realized that would make it have a different order than the parent initializer calls. We document that the parent initializer calls should be in linearization order, and the Upgrades Plugins would give a warning if they are not.

We should aim to eventually stabilize and reorganize these, but it may require a larger change in how the code is generated in order to do this properly.

Opened #750 to track this as an enhancement request.

ericglau and others added 2 commits December 8, 2025 11:30
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
@ericglau ericglau changed the title Add ERC-20 option for embedding ERC-7786 based crosschain bridge Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0 Dec 19, 2025
@ericglau ericglau changed the title Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0 Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0-rc.0 Dec 19, 2025
@ericglau ericglau enabled auto-merge (squash) December 19, 2025 23:30
@ericglau ericglau disabled auto-merge December 20, 2025 01:43
@ericglau ericglau marked this pull request as draft December 22, 2025 16:49
@ericglau
Copy link
Member Author

Leaving as Draft to avoid merging until 5.6.0 final version is released.

Copy link

@pasevin pasevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ericglau ericglau changed the title Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0-rc.0 Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0 Feb 25, 2026
@ericglau ericglau marked this pull request as ready for review February 25, 2026 20:15
@ericglau ericglau merged commit 32ff02c into OpenZeppelin:master Feb 25, 2026
21 checks passed
@ericglau ericglau deleted the erc20crosschain branch February 25, 2026 20:31
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants