Skip to content

fix(cctp): use testnet RPC endpoints on testnet - #208

Merged
0xdevcollins merged 1 commit into
mainfrom
fix/cctp-testnet-rpc
Aug 9, 2026
Merged

fix(cctp): use testnet RPC endpoints on testnet#208
0xdevcollins merged 1 commit into
mainfrom
fix/cctp-testnet-rpc

Conversation

@0xdevcollins

Copy link
Copy Markdown
Owner

Fixes the 401 Unauthorized from eth-mainnet.g.alchemy.com hit while testing an Ethereum payment on testnet.

What was wrong

A chain id is the same string on both networks — ethereum means mainnet or Sepolia depending only on STELLAR_NETWORK, and only 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 a mainnet node.

Confirmed rather than assumed — eth_getCode for Sepolia USDC 0x1c7D4B19…:

node result
Sepolia 3598 bytes — contract present
Ethereum mainnet 0x — nothing deployed

So 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:

chain endpoint eth_chainId
ethereum ethereum-sepolia-rpc.publicnode.com 11155111 ✅
base sepolia.base.org 84532 ✅
arbitrum sepolia-rollup.arbitrum.io/rpc 421614 ✅
optimism sepolia.optimism.io 11155420 ✅
avalanche api.avax-test.network 43113 ✅

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.

Verified against the running API

POST /v1/checkout/:id/select-crypto with sourceChain: ethereum now returns chainId: 11155111 with 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.

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>
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
useroutr-www Ready Ready Preview Aug 9, 2026 9:00pm

@0xdevcollins
0xdevcollins merged commit cb204ef into main Aug 9, 2026
8 checks passed
@0xdevcollins
0xdevcollins deleted the fix/cctp-testnet-rpc branch August 9, 2026 21:06
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