Skip to content

Conversation

@mikeahirsch
Copy link

@mikeahirsch mikeahirsch commented Nov 21, 2025

Description and Related Issue(s)

Adds support for Facet L2 networks in the Blockscout contract interaction UI by integrating the Facet SDK, while preserving existing behavior for all non-Facet chains. When the current chain is a Facet chain, contract calls and value transfers are routed through the Facet SDK helper functions; otherwise, the existing viem/wagmi flow is used unchanged.

No specific GitHub issue to link; this is an integration enhancement.

Proposed Changes

  • Add Facet SDK integration to contract method calls

    • Update useCallMethodWalletClient to detect when the configured chain is facetMainnet or facetSepolia.
    • When on a Facet chain, derive the parent L1 chain ID from config.features.rollup.parentChain and use that as the targetChainId.
    • Ensure the connected wallet and walletClient are on targetChainId (switching chains as needed).
    • For receive/fallback (native value send) calls, use sendFacetTransaction on Facet chains and keep walletClient.sendTransaction for non-Facet chains.
    • For contract method writes, use writeFacetContract on Facet chains and keep walletClient.writeContract for non-Facet chains, reusing the existing ABI/method-name workaround.
    • Share common request payloads (txRequest, writeRequest) between Facet and non-Facet code paths to avoid duplication.
  • Dependencies

    • Add @0xfacet/sdk dependency (used for Facet chain detection and Facet transaction helpers).
  • ENV variables

    • No new ENV variables are introduced.
    • Reuse existing rollup configuration (config.features.rollup and its parentChain) to locate the correct L1 chain for Facet.

Breaking or Incompatible Changes

  • No breaking or incompatible changes expected.
  • For non-Facet chains, the behavior of contract interactions and native value sends is unchanged.
  • For Facet-enabled deployments, behavior is additive: when the chain ID matches a Facet network, the hook now uses the Facet SDK under the hood, but the external call site and return shape remain the same.

Additional Information

  • This change is scoped to the smart contract interaction flow (useCallMethodWalletClient) and is intended to be a minimal, backwards-compatible integration layer on top of the existing viem/wagmi setup.

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@mikeahirsch
Copy link
Author

This change is already running in production at the Facet explorer: explorer.facet.org.

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.

1 participant