From f191215340968a96395a4107770ac87329419a1d Mon Sep 17 00:00:00 2001 From: Haaaarry <965628765@qq.com> Date: Mon, 17 Aug 2026 00:16:05 +0800 Subject: [PATCH] feat: add Plasma mainnet and testnet support Add Plasma mainnet (9745) and testnet (9746) via defineChain, since viem 2.39.3 does not export them. RPC endpoints verified against chainid.network. --- README.md | 2 ++ src/core/chains.ts | 54 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cdbac53..b0dddf4 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ All services are exposed through a consistent interface of MCP tools, resources, - Canto - Flow - Lumia +- Plasma ### Testnets @@ -171,6 +172,7 @@ All services are exposed through a consistent interface of MCP tools, resources, - Flow Testnet - Filecoin Calibration - Lumia Testnet +- Plasma Testnet ## 🛠️ Prerequisites diff --git a/src/core/chains.ts b/src/core/chains.ts index 75115d3..6c43823 100644 --- a/src/core/chains.ts +++ b/src/core/chains.ts @@ -1,4 +1,4 @@ -import { type Chain } from 'viem'; +import { type Chain, defineChain } from 'viem'; import { // Mainnets mainnet, @@ -60,6 +60,51 @@ import { filecoinCalibration } from 'viem/chains'; +// Plasma (XPL) - not yet exported by viem/chains as of viem 2.39.3. +// Mainnet (id 9745) and testnet (id 9746) per chainid.network / ethereum-lists. +export const plasma = defineChain({ + id: 9745, + name: 'Plasma', + nativeCurrency: { + name: 'Plasma', + symbol: 'XPL', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://rpc.plasma.to'], + }, + }, + blockExplorers: { + default: { + name: 'Plasma Explorer', + url: 'https://plasmascan.to', + }, + }, +}); + +export const plasmaTestnet = defineChain({ + id: 9746, + name: 'Plasma Testnet', + nativeCurrency: { + name: 'Testnet Plasma', + symbol: 'XPL', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://testnet-rpc.plasma.to'], + }, + }, + blockExplorers: { + default: { + name: 'Plasma Testnet Explorer', + url: 'https://testnet.plasmascan.to', + }, + }, + testnet: true, +}); + // Default configuration values export const DEFAULT_RPC_URL = 'https://eth.llamarpc.com'; export const DEFAULT_CHAIN_ID = 1; @@ -98,6 +143,7 @@ export const chainMap: Record = { 1313161554: aurora, 7700: canto, 747: flowMainnet, + 9745: plasma, // Testnets 11155111: sepolia, @@ -124,6 +170,7 @@ export const chainMap: Record = { 17000: holesky, 545: flowTestnet, 314159: filecoinCalibration, + 9746: plasmaTestnet, }; // Map network names to chain IDs for easier reference @@ -172,6 +219,7 @@ export const networkNameMap: Record = { 'aurora': 1313161554, 'canto': 7700, 'flow': 747, + 'plasma': 9745, // Testnets 'sepolia': 11155111, @@ -218,6 +266,8 @@ export const networkNameMap: Record = { 'holesky': 17000, 'flow-testnet': 545, 'filecoin-calibration': 314159, + 'plasma-testnet': 9746, + 'plasmatestnet': 9746, }; // Map chain IDs to RPC URLs @@ -254,6 +304,7 @@ export const rpcUrlMap: Record = { 1313161554: 'https://mainnet.aurora.dev', 7700: 'https://canto.gravitychain.io', 747: 'https://mainnet.evm.nodes.onflow.org', + 9745: 'https://rpc.plasma.to', // Testnets 11155111: 'https://sepolia.drpc.org', @@ -280,6 +331,7 @@ export const rpcUrlMap: Record = { 17000: 'https://ethereum-holesky.publicnode.com', 545: 'https://testnet.evm.nodes.onflow.org', 314159: 'https://api.calibration.node.glif.io/rpc/v1', + 9746: 'https://testnet-rpc.plasma.to', }; /**