Skip to content

Add wallet_addEthereumChain fallback for unknown chains#4

Closed
juntao wants to merge 1 commit intomainfrom
fix-chain-not-found
Closed

Add wallet_addEthereumChain fallback for unknown chains#4
juntao wants to merge 1 commit intomainfrom
fix-chain-not-found

Conversation

@juntao
Copy link
Copy Markdown
Member

@juntao juntao commented Feb 2, 2026

Summary

  • Fixed MetaMask error "Unrecognized chain ID" when chain is not configured
  • When wallet_switchEthereumChain fails with error code 4902, now calls wallet_addEthereumChain to add the chain first
  • Added chain configurations for Base Mainnet, Base Sepolia, Ethereum Mainnet, and Ethereum Sepolia

Test plan

  • Open the payment page in a browser with MetaMask that doesn't have Base Sepolia configured
  • Click "Pay Now" on a payment link
  • Verify MetaMask prompts to add the Base Sepolia network
  • After adding, verify the payment flow continues

🤖 Generated with Claude Code

When MetaMask doesn't have a chain configured, wallet_switchEthereumChain
fails with error code 4902. Now we catch this error and add the chain
using wallet_addEthereumChain with predefined configurations for:
- Base Mainnet (8453)
- Base Sepolia (84532)
- Ethereum Mainnet (1)
- Ethereum Sepolia (11155111)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@juntao juntao closed this Feb 3, 2026
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.

2 participants