Repository navigation
Expand file tree
/
Copy pathchains.js
More file actions
107 lines (103 loc) · 12.1 KB
/
Copy pathchains.js
File metadata and controls
107 lines (103 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const CHAINS = [
{ key: "0g", name: "0G", chainId: 16661, rpc: "https://evmrpc.0g.ai", explorerBase: "https://chainscan.0g.ai", currency: "0G" },
{ key: "apechain", name: "ApeChain", chainId: 33139, rpc: "https://rpc.apechain.com", explorerBase: "https://apescan.io", currency: "APE" },
{ key: "arbitrum-one", name: "Arbitrum One", chainId: 42161, rpc: "https://arb1.arbitrum.io/rpc", explorerBase: "https://arbiscan.io", currency: "ETH" },
{ key: "arc", name: "Arc", chainId: 5042, rpc: "https://rpc.mainnet.arc.io", explorerBase: "https://explorer.arc.io", currency: "USDC" }, // gas is paid in USDC
{ key: "avalanche-c-chain", name: "Avalanche C-Chain", chainId: 43114, rpc: "https://api.avax.network/ext/bc/C/rpc", explorerBase: "https://snowscan.xyz", currency: "AVAX" },
{ key: "base", name: "Base", chainId: 8453, rpc: "https://base-rpc.publicnode.com", explorerBase: "https://basescan.org", currency: "ETH" },
{ key: "berachain", name: "Berachain", chainId: 80094, rpc: "https://rpc.berachain.com", explorerBase: "https://berascan.com", currency: "BERA" },
{ key: "blast", name: "Blast", chainId: 81457, rpc: "https://rpc.blast.io", explorerBase: "https://blastscan.io", currency: "ETH" },
{ key: "bnb-smart-chain", name: "BNB Smart Chain", chainId: 56, rpc: "https://bsc-dataseed1.bnbchain.org", explorerBase: "https://bscscan.com", currency: "BNB" },
{ key: "celo", name: "Celo", chainId: 42220, rpc: "https://forno.celo.org", explorerBase: "https://celoscan.io", currency: "CELO" },
{ key: "chiliz", name: "Chiliz", chainId: 88888, rpc: "https://rpc.chiliz.com", explorerBase: "https://chiliscan.com", currency: "CHZ" },
{ key: "conflux-evm-espace", name: "Conflux EVM eSpace", chainId: 1030, rpc: "https://evm.confluxrpc.com", explorerBase: "https://evm.confluxscan.net", currency: "CFX" },
{ key: "core-blockchain", name: "Core Blockchain", chainId: 1116, rpc: "https://rpc.coredao.org", explorerBase: "https://scan.coredao.org", currency: "CORE" },
{ key: "coti", name: "COTI", chainId: 2632500, rpc: "https://mainnet.coti.io/rpc", explorerBase: "https://mainnet.cotiscan.io", currency: "COTI" },
{ key: "cronos", name: "Cronos", chainId: 25, rpc: "https://evm.cronos.org", explorerBase: "https://explorer.cronos.org", currency: "CRO" },
{ key: "degen-chain", name: "Degen Chain", chainId: 666666666, rpc: "https://rpc.degen.tips", explorerBase: null, currency: "DEGEN" },
{ key: "ethereum", name: "Ethereum", chainId: 1, rpc: "https://ethereum-rpc.publicnode.com", explorerBase: "https://etherscan.io", currency: "ETH" },
{ key: "ethereum-classic", name: "Ethereum Classic", chainId: 61, rpc: "https://etc.rivet.link", explorerBase: "https://etc.blockscout.com", currency: "ETC" },
{ key: "etherlink", name: "Etherlink", chainId: 42793, rpc: "https://node.mainnet.etherlink.com", explorerBase: "https://explorer.etherlink.com", currency: "XTZ" },
{ key: "flare", name: "Flare", chainId: 14, rpc: "https://flare-api.flare.network/ext/C/rpc", explorerBase: "https://flare-explorer.flare.network", currency: "FLR" },
{ key: "gnosis", name: "Gnosis", chainId: 100, rpc: "https://rpc.gnosischain.com", explorerBase: "https://gnosisscan.io", currency: "XDAI" },
{ key: "gravity-alpha", name: "Gravity Alpha", chainId: 1625, rpc: "https://rpc.gravity.xyz", explorerBase: "https://explorer.gravity.xyz", currency: "G" },
{ key: "hashkey-chain", name: "HashKey Chain", chainId: 177, rpc: "https://mainnet.hsk.xyz", explorerBase: "https://hsk.blockscout.com", currency: "HSK" },
{ key: "immutable-zkevm", name: "Immutable zkEVM", chainId: 13371, rpc: "https://rpc.immutable.com", explorerBase: "https://explorer.immutable.com", currency: "IMX" },
{ key: "ink", name: "Ink", chainId: 57073, rpc: "https://rpc-gel.inkonchain.com", explorerBase: "https://explorer.inkonchain.com", currency: "ETH" },
{ key: "katana", name: "Katana", chainId: 747474, rpc: "https://rpc.katana.network", explorerBase: "https://katanascan.com", currency: "ETH" },
{ key: "kava-evm", name: "Kava EVM", chainId: 2222, rpc: "https://evm.kava.io", explorerBase: "https://kavascan.com", currency: "KAVA" },
{ key: "lens", name: "Lens", chainId: 232, rpc: "https://rpc.lens.xyz", explorerBase: "https://explorer.lens.xyz", currency: "GHO" },
{ key: "linea", name: "Linea", chainId: 59144, rpc: "https://rpc.linea.build", explorerBase: "https://lineascan.build", currency: "ETH" },
{ key: "mantle", name: "Mantle", chainId: 5000, rpc: "https://rpc.mantle.xyz", explorerBase: "https://mantlescan.xyz", currency: "MNT" },
{ key: "megaeth", name: "MegaETH", chainId: 4326, rpc: "https://mainnet.megaeth.com/rpc", explorerBase: "https://mega.etherscan.io", currency: "ETH" },
{ key: "mode", name: "Mode", chainId: 34443, rpc: "https://mainnet.mode.network", explorerBase: "https://explorer.mode.network", currency: "ETH" },
{ key: "monad", name: "Monad", chainId: 143, rpc: "https://rpc.monad.xyz", explorerBase: "https://monadvision.com", currency: "MON" },
{ key: "moonbeam", name: "Moonbeam", chainId: 1284, rpc: "https://rpc.api.moonbeam.network", explorerBase: "https://moonbeam.moonscan.io", currency: "GLMR" },
{ key: "moonriver", name: "Moonriver", chainId: 1285, rpc: "https://rpc.api.moonriver.moonbeam.network", explorerBase: "https://moonriver.moonscan.io", currency: "MOVR" },
{ key: "optimism", name: "Optimism", chainId: 10, rpc: "https://mainnet.optimism.io", explorerBase: "https://optimistic.etherscan.io", currency: "ETH" },
{ key: "plasma", name: "Plasma", chainId: 9745, rpc: "https://rpc.plasma.to", explorerBase: "https://plasmascan.to", currency: "XPL" },
{ key: "plume", name: "Plume", chainId: 98866, rpc: "https://rpc.plume.org", explorerBase: "https://explorer.plume.org", currency: "PLUME" },
{ key: "polygon", name: "Polygon", chainId: 137, rpc: "https://polygon-bor-rpc.publicnode.com", explorerBase: "https://polygonscan.com", currency: "POL" },
{ key: "pulsechain", name: "Pulsechain", chainId: 369, rpc: "https://rpc.pulsechain.com", explorerBase: "https://ipfs.scan.pulsechain.com", currency: "PLS" },
{ key: "ronin", name: "Ronin", chainId: 2020, rpc: "https://api.roninchain.com/rpc", explorerBase: "https://app.roninchain.com", currency: "RON" },
{ key: "scroll", name: "Scroll", chainId: 534352, rpc: "https://rpc.scroll.io", explorerBase: "https://scrollscan.com", currency: "ETH" },
{ key: "somnia", name: "Somnia", chainId: 5031, rpc: "https://api.infra.mainnet.somnia.network", explorerBase: "https://mainnet.somnia.w3us.site", currency: "SOMI" },
{ key: "soneium", name: "Soneium", chainId: 1868, rpc: "https://rpc.soneium.org", explorerBase: "https://soneium.blockscout.com", currency: "ETH" },
{ key: "sonic", name: "Sonic", chainId: 146, rpc: "https://rpc.soniclabs.com", explorerBase: "https://sonicscan.org", currency: "S" },
{ key: "stable", name: "Stable", chainId: 988, rpc: "https://rpc.stable.xyz", explorerBase: "https://stablescan.xyz", currency: "USDT0" },
{ key: "story", name: "Story", chainId: 1514, rpc: "https://mainnet.datarpc.io", explorerBase: "https://datanetscan.io", currency: "DATA" },
{ key: "stratis-xertra", name: "Stratis Xertra", chainId: 105105, rpc: "https://rpc.xertra.com", explorerBase: "https://explorer.xertra.com", currency: "STRAX" },
{ key: "taiko-alethia", name: "Taiko Alethia", chainId: 167000, rpc: "https://rpc.mainnet.taiko.xyz", explorerBase: "https://taikoscan.io", currency: "ETH" },
{ key: "telos-evm", name: "Telos EVM", chainId: 40, rpc: "https://rpc.telos.net", explorerBase: "https://teloscan.io", currency: "TLOS" },
{ key: "tempo", name: "Tempo", chainId: 4217, rpc: "https://rpc.mainnet.tempo.xyz", explorerBase: "https://explore.tempo.xyz", currency: "USD" },
{ key: "unichain", name: "Unichain", chainId: 130, rpc: "https://mainnet.unichain.org", explorerBase: "https://uniscan.xyz", currency: "ETH" },
{ key: "world-chain", name: "World Chain", chainId: 480, rpc: "https://worldchain-mainnet.g.alchemy.com/public", explorerBase: "https://worldscan.org", currency: "ETH" },
{ key: "x-layer", name: "X Layer", chainId: 196, rpc: "https://rpc.xlayer.tech", explorerBase: "https://www.oklink.com/xlayer", currency: "OKB" },
{ key: "xai", name: "Xai", chainId: 660279, rpc: "https://xai-chain.net/rpc", explorerBase: "https://explorer.xai-chain.net", currency: "XAI" },
{ key: "xdc-network", name: "XDC Network", chainId: 50, rpc: "https://erpc.xinfin.network", explorerBase: "https://xdcscan.com", currency: "XDC" },
{ key: "zetachain", name: "ZetaChain", chainId: 7000, rpc: "https://zetachain-evm.blockpi.network/v1/rpc/public", explorerBase: "https://zetascan.com", currency: "ZETA" },
{ key: "zksync", name: "zkSync", chainId: 324, rpc: "https://mainnet.era.zksync.io", explorerBase: "https://explorer.zksync.io", currency: "ETH" },
{ key: "zora", name: "Zora", chainId: 7777777, rpc: "https://rpc.zora.energy", explorerBase: "https://explorer.zora.energy", currency: "ETH" },
{ key: "arbitrum-sepolia", name: "Arbitrum Sepolia (testnet)", chainId: 421614, rpc: "https://sepolia-rollup.arbitrum.io/rpc", explorerBase: "https://sepolia.arbiscan.io", currency: "ETH" },
{ key: "base-sepolia", name: "Base Sepolia (testnet)", chainId: 84532, rpc: "https://sepolia.base.org", explorerBase: "https://sepolia.basescan.org", currency: "ETH" },
{ key: "ethereum-hoodi", name: "Ethereum Hoodi (testnet)", chainId: 560048, rpc: "https://rpc.hoodi.ethpandaops.io", explorerBase: "https://light-hoodi.beaconcha.in", currency: "ETH" },
{ key: "ethereum-sepolia", name: "Ethereum Sepolia (testnet)", chainId: 11155111, rpc: "https://rpc.sepolia.org", explorerBase: "https://sepolia.etherscan.io", currency: "ETH" },
{ key: "polygon-amoy", name: "Polygon Amoy (testnet)", chainId: 80002, rpc: "https://rpc-amoy.polygon.technology", explorerBase: "https://amoy.polygonscan.com", currency: "POL" },
{ key: "zksync-sepolia", name: "zkSync Sepolia (testnet)", chainId: 300, rpc: "https://sepolia.era.zksync.dev", explorerBase: "https://sepolia.explorer.zksync.io", currency: "ETH" },
{ key: "sei", name: "Sei", chainId: 1329, rpc: "https://evm-rpc.sei-apis.com", explorerBase: "https://seitrace.com", currency: "SEI" },
{ key: "custom", name: "Custom RPC...", chainId: null, rpc: null, explorerBase: null, currency: "?" },
];
// LUKSO itself: not in CHAINS, which lists the networks a UP can be redeployed to. Pages that act on
// the UP where it already lives (UP Wallet) add it to their own list.
const LUKSO_CHAIN = { key: "lukso", name: "LUKSO", chainId: 42, rpc: "https://rpc.mainnet.lukso.network", explorerBase: "https://explorer.execution.mainnet.lukso.network", currency: "LYX" };
// The parameters of wallet_addEthereumChain for a network of these lists, for a wallet that does not
// know it yet. Native currencies are taken as 18 decimals, as on every network listed here.
function addChainParams(net, chainId = net.chainId) {
const p = { chainId: "0x" + Number(chainId).toString(16), chainName: net.name, rpcUrls: [net.rpc],
nativeCurrency: { name: net.currency, symbol: net.currency, decimals: 18 } };
if (net.explorerBase) p.blockExplorerUrls = [net.explorerBase];
return p;
}
function getExplorerUrl(net, path, resource) {
const base = net.explorerBase ? net.explorerBase + path : net.explorer;
return base ? base + resource : null;
}
// Waits for a transaction receipt by asking the RPC every 1.5 seconds. Errors while waiting are
// ignored and the next attempt follows: some public RPCs refuse receipt lookups (publicnode answers
// 403 "archive requests require a personal token", before the transaction is in a block and, on
// Base, sometimes after). `fallback` is the signing wallet's provider (an ethers BrowserProvider):
// when the RPC has no answer, the wallet is asked too, since it tracks the transaction it sent.
// Returns the receipt, or null after `timeoutMs`.
async function waitReceipt(provider, hash, fallback = null, timeoutMs = 60000) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
for (const p of fallback ? [provider, fallback] : [provider]) {
try {
const receipt = await p.getTransactionReceipt(hash);
if (receipt) return receipt;
} catch (e) { /* not known to this source yet: ask again */ }
}
await new Promise((r) => setTimeout(r, 1500));
}
return null;
}