Skip to content

Commit 4e0c8fa

Browse files
authored
feat: make supported chains list dynamic via getSupportedChains API (#1239)
* feat: make supported chains list dynamic via getSupportedChains API * fix: update supported chains
1 parent 4a58455 commit 4e0c8fa

3 files changed

Lines changed: 113 additions & 7 deletions

File tree

docs/base-account/overview/what-is-base-account.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ A Base Account is a Smart-Wallet–backed account that gives every user:
1212
* **Universal sign-on** – one passkey works across every Base-enabled app.
1313
* **One-tap payments** – low-friction USDC payments built into the account layer.
1414
* **Private profile vault** – opt-in sharing of email, phone, shipping address, and more.
15-
* **Multi-chain support** – one address that works across nine EVM networks (and counting).
15+
* **Multi-chain support** – one address that works across many EVM networks.
1616

17-
> Under the hood, each Base Account is an ERC-4337 Smart Wallet that can be deployed on any EVM-compatible chain; nine EVM mainnet chains are enabled out of the box, including Base Mainnet.
17+
> Under the hood, each Base Account is an ERC-4337 Smart Wallet that can be deployed on any EVM-compatible chain; many EVM mainnet chains are enabled out of the box, including Base Mainnet.
1818
19-
<Note>
20-
**Supported networks**
19+
import SupportedChains from "/snippets/supported-chains.mdx";
2120

22-
- **Mainnet:** Base • Arbitrum • Optimism • Zora • Polygon • BNB • Avalanche • Lordchain • Ethereum Mainnet (not recommended due to costs)
23-
- **Testnet:** Sepolia • Base Sepolia
24-
</Note>
21+
<SupportedChains />
2522

2623
## Why should developers care?
2724

docs/snippets/supported-chains.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{/* Auto-generated by scripts/update-supported-chains.sh — do not edit manually */}
2+
3+
<Note>
4+
**Supported networks**
5+
6+
**Full support**
7+
- **Mainnet:** Base • Arbitrum • Optimism • Zora • Polygon • BNB Chain • Avalanche • Ethereum
8+
- **Testnet:** Base Sepolia • Sepolia
9+
10+
{/* DYNAMIC_CHAINS_START */}
11+
**Basic support:** Monad • Unichain • ZKsync
12+
13+
Basic support only includes transfers through the [Base Account Web](https://account.base.app) surface for select tokens.
14+
{/* DYNAMIC_CHAINS_END */}
15+
</Note>

scripts/update-supported-chains.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
# Fetches the SCW getSupportedChains API and regenerates the
3+
# docs/snippets/supported-chains.mdx file, inserting any chains
4+
# tagged "simple-chain" into the dynamic section.
5+
#
6+
# Usage:
7+
# bash scripts/update-supported-chains.sh
8+
#
9+
# The snippet has two parts:
10+
# 1. Hardcoded core chains (manually maintained above the markers)
11+
# 2. Dynamic "basic chains" pulled from the API (between the markers)
12+
#
13+
# Only chains with the "simple-chain" tag are inserted dynamically.
14+
# If none are found, the dynamic section is left empty.
15+
16+
set -euo pipefail
17+
18+
API_URL="${API_URL:-https://api.wallet.coinbase.com/rpc/v3/scw/getSupportedChains}"
19+
SNIPPET="docs/snippets/supported-chains.mdx"
20+
21+
# Resolve paths relative to repo root
22+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
23+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
24+
SNIPPET_PATH="$REPO_ROOT/$SNIPPET"
25+
26+
if [ ! -f "$SNIPPET_PATH" ]; then
27+
echo "Error: $SNIPPET not found at $SNIPPET_PATH" >&2
28+
exit 1
29+
fi
30+
31+
# Fetch the API
32+
RESPONSE=$(curl -sf "$API_URL") || {
33+
echo "Error: failed to fetch $API_URL" >&2
34+
exit 1
35+
}
36+
37+
# Extract simple-chain entries grouped by mainnet/testnet
38+
DYNAMIC_BLOCK=$(echo "$RESPONSE" | python3 -c "
39+
import sys, json
40+
41+
data = json.load(sys.stdin)
42+
chains = data.get('chains', [])
43+
44+
simple = [c for c in chains if 'simple-chain' in c.get('tags', [])]
45+
46+
if not simple:
47+
sys.exit(0) # nothing to output
48+
49+
mainnets = sorted([c['name'] for c in simple if 'testnet' not in c['networkId']])
50+
testnets = sorted([c['name'] for c in simple if 'testnet' in c['networkId']])
51+
52+
all_simple = sorted(mainnets + testnets)
53+
54+
lines = []
55+
lines.append('**Basic support:** ' + ' • '.join(all_simple))
56+
lines.append('')
57+
lines.append('Basic support only includes transfers through the [Base Account Web](https://account.base.app) surface for select tokens.')
58+
59+
print('\n'.join(lines))
60+
")
61+
62+
# Replace content between the markers in the snippet
63+
python3 -c "
64+
import sys
65+
66+
snippet_path = sys.argv[1]
67+
dynamic_block = sys.argv[2]
68+
69+
with open(snippet_path, 'r') as f:
70+
content = f.read()
71+
72+
start_marker = '{/* DYNAMIC_CHAINS_START */}'
73+
end_marker = '{/* DYNAMIC_CHAINS_END */}'
74+
75+
start_idx = content.find(start_marker)
76+
end_idx = content.find(end_marker)
77+
78+
if start_idx == -1 or end_idx == -1:
79+
print('Error: markers not found in snippet', file=sys.stderr)
80+
sys.exit(1)
81+
82+
# Build the replacement: markers + dynamic content between them
83+
if dynamic_block.strip():
84+
replacement = start_marker + '\n' + dynamic_block + '\n' + end_marker
85+
else:
86+
replacement = start_marker + '\n' + end_marker
87+
88+
new_content = content[:start_idx] + replacement + content[end_idx + len(end_marker):]
89+
90+
with open(snippet_path, 'w') as f:
91+
f.write(new_content)
92+
" "$SNIPPET_PATH" "$DYNAMIC_BLOCK"
93+
94+
echo "Updated $SNIPPET"

0 commit comments

Comments
 (0)