fix(cctp): use testnet RPC endpoints on testnet - #208
Merged
Conversation
A chain id is the same string on both networks — `ethereum` means mainnet or Sepolia depending only on `STELLAR_NETWORK`, and just the contract addresses switch. But the RPC lookup was `RPC_<CHAIN>` with no network in it, so a testnet payment read Sepolia's USDC and TokenMessenger addresses off whatever `RPC_ETHEREUM` pointed at, which is a mainnet node. Nothing is deployed at those addresses on mainnet. Confirmed rather than assumed: `eth_getCode` for Sepolia USDC 0x1c7D4B19… returns 3598 bytes on a Sepolia node and `0x` on a mainnet one. So the call could only fail — as an empty revert, or, when the mainnet URL carried a stale or placeholder key, as a bare 401 from the provider that reads like a credentials problem rather than a wrong-network one. On testnet the override is now `RPC_<CHAIN>_TESTNET`, falling back to that chain's own published endpoint. All five CCTP chains have one, so a local testnet run needs no third-party key: cloning the repo and paying on Sepolia should not first require an Alchemy signup. Each default was checked against the live network — eth_chainId returns 11155111, 84532, 421614, 11155420 and 43113 respectively. Mainnet keeps `RPC_<CHAIN>` and deliberately gets no fallback. Quietly routing real money through a rate-limited public endpoint is not a favour, and doing it silently is worse. Tests: 297 (10 new), covering both networks, the explicit override, every default, and the two failure messages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
401 Unauthorizedfrometh-mainnet.g.alchemy.comhit while testing an Ethereum payment on testnet.What was wrong
A chain id is the same string on both networks —
ethereummeans mainnet or Sepolia depending only onSTELLAR_NETWORK, and only the contract addresses switch. But the RPC lookup wasRPC_<CHAIN>, with no network in it. So a testnet payment read Sepolia's USDC and TokenMessenger addresses off a mainnet node.Confirmed rather than assumed —
eth_getCodefor Sepolia USDC0x1c7D4B19…:0x— nothing deployedSo the call could only fail. Usually as an empty revert; and when the mainnet URL carried a stale or placeholder key, as a bare 401 from the provider — which reads like a credentials problem rather than a wrong-network one. That is the error in the report.
The fix
On testnet the override is
RPC_<CHAIN>_TESTNET, falling back to that chain's own published endpoint. All five CCTP chains have a working default, so a local testnet run needs no third-party key — cloning the repo and paying on Sepolia shouldn't first require an Alchemy signup.Each default was verified against the live network:
eth_chainIdMainnet keeps
RPC_<CHAIN>and deliberately gets no fallback. Quietly routing real money through a rate-limited public endpoint is not a favour, and doing it silently is worse.Verified against the running API
POST /v1/checkout/:id/select-cryptowithsourceChain: ethereumnow returnschainId: 11155111with the Sepolia USDC address and real approve + burn calldata.Tests: 297 (10 new) — both networks, the explicit override, every default, and both failure messages. 0 lint errors.