Skip to content

Commit 89327d6

Browse files
committed
UI update supporting evm connection
1 parent ba9b957 commit 89327d6

File tree

684 files changed

+647
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+647
-81
lines changed

packages/backend/src/services/balance.ts

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Balance service for tokens on Solana and Base
1+
// Balance service for tokens on Solana and EVM chains
22

33
import { Connection, PublicKey } from '@solana/web3.js';
44
import { getAssociatedTokenAddress, getAccount } from '@solana/spl-token';
55
import { createPublicClient, http, formatUnits, type Address } from 'viem';
6-
import { base } from 'viem/chains';
6+
import { base, mainnet, bsc, polygon, arbitrum, avalanche } from 'viem/chains';
77
import { CHAINS } from '../config/chains.js';
8+
import { USDC_ADDRESSES } from '../config/cctp-contracts.js';
89
import type Redis from 'ioredis';
910

1011
const ERC20_ABI = [
@@ -26,6 +27,18 @@ const ERC20_ABI = [
2627

2728
const BALANCE_CACHE_TTL = 30; // 30 seconds cache
2829

30+
// EVM Chain configurations
31+
const EVM_CHAINS = {
32+
ethereum: { chain: mainnet, rpcUrl: process.env.BASE_RPC_URL?.replace('/base', '/eth') || 'https://ethereum.publicnode.com' },
33+
base: { chain: base, rpcUrl: process.env.BASE_RPC_URL || 'https://mainnet.base.org' },
34+
bnb: { chain: bsc, rpcUrl: process.env.BASE_RPC_URL?.replace('/base', '/bnb') || 'https://bsc-dataseed.binance.org' },
35+
polygon: { chain: polygon, rpcUrl: process.env.BASE_RPC_URL?.replace('/base', '/polygon') || 'https://polygon-rpc.com' },
36+
arbitrum: { chain: arbitrum, rpcUrl: process.env.BASE_RPC_URL?.replace('/base', '/arb') || 'https://arb1.arbitrum.io/rpc' },
37+
avalanche: { chain: avalanche, rpcUrl: process.env.BASE_RPC_URL?.replace('/base', '/avax') || 'https://api.avax.network/ext/bc/C/rpc' },
38+
} as const;
39+
40+
type EVMChainName = keyof typeof EVM_CHAINS;
41+
2942
export interface BalanceResult {
3043
chain: string;
3144
address: string;
@@ -116,7 +129,7 @@ export async function getBalance(chain: string, address: string): Promise<Balanc
116129
* Get token balance for any supported token on any chain with Redis caching
117130
*/
118131
export async function getTokenBalance(
119-
chain: 'solana' | 'base' | 'monad',
132+
chain: string,
120133
address: string,
121134
token: string,
122135
tokenAddress: string | undefined,
@@ -142,11 +155,10 @@ export async function getTokenBalance(
142155

143156
if (chain === 'solana') {
144157
result = await getSolanaTokenBalance(address, token, tokenAddress);
145-
} else if (chain === 'base') {
146-
result = await getBaseTokenBalance(address, token, tokenAddress);
158+
} else if (chain in EVM_CHAINS) {
159+
result = await getEVMTokenBalance(chain as EVMChainName, address, token, tokenAddress);
147160
} else {
148-
// Monad not yet supported
149-
result = { balance: '0', decimals: 18 };
161+
throw new Error(`Unsupported chain: ${chain}`);
150162
}
151163

152164
// Cache the result
@@ -204,28 +216,48 @@ async function getSolanaTokenBalance(
204216
}
205217
}
206218

207-
async function getBaseTokenBalance(
219+
/**
220+
* Generic EVM token balance getter - works for all EVM chains
221+
*/
222+
async function getEVMTokenBalance(
223+
chainName: EVMChainName,
208224
address: string,
209225
token: string,
210226
tokenAddress?: string
211227
): Promise<TokenBalanceResult> {
212-
const config = CHAINS.base;
228+
const config = EVM_CHAINS[chainName];
213229
const client = createPublicClient({
214-
chain: base,
230+
chain: config.chain,
215231
transport: http(config.rpcUrl),
216232
});
217233

218234
const addr = address as Address;
219235

220-
if (token === 'ETH' || (!tokenAddress && token.toUpperCase() === 'ETH')) {
221-
// Native ETH balance
236+
// Native token balances (ETH, POL, AVAX, etc.)
237+
const nativeTokens = ['ETH', 'POL', 'BNB', 'ARB', 'AVAX'];
238+
if (nativeTokens.includes(token.toUpperCase()) || (!tokenAddress && nativeTokens.includes(token.toUpperCase()))) {
222239
const balance = await client.getBalance({ address: addr });
223240
return {
224241
balance: formatUnits(balance, 18),
225242
decimals: 18,
226243
};
227244
}
228245

246+
// USDC balance - use CCTP addresses
247+
if (token.toUpperCase() === 'USDC' && !tokenAddress) {
248+
const usdcAddress = USDC_ADDRESSES[chainName as keyof typeof USDC_ADDRESSES];
249+
if (!usdcAddress) {
250+
// BNB Chain uses a different USDC (not Circle's)
251+
if (chainName === 'bnb') {
252+
tokenAddress = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d'; // USDC on BNB Chain
253+
} else {
254+
throw new Error(`USDC not supported on ${chainName}`);
255+
}
256+
} else {
257+
tokenAddress = usdcAddress;
258+
}
259+
}
260+
229261
// ERC20 Token balance
230262
if (!tokenAddress) {
231263
throw new Error('Token address required for ERC20 tokens');

packages/frontend/index.html

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,43 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88

99
<!-- Primary Meta Tags -->
10-
<title>Monrail - Fastest rail Solana > EVM</title>
11-
<meta name="title" content="Monrail - Fastest rail Solana > EVM" />
10+
<title>Monrail - Fastest Bridge to MONAD | Day One Support</title>
11+
<meta name="title" content="Monrail - Fastest Bridge to MONAD | Day One Support" />
1212
<meta name="description"
13-
content="Cross-chain transfers in seconds. Extremely low fee, only 0.69 USD per transaction." />
13+
content="The fastest blockchain bridge to MONAD with day one support. Cross-chain transfers in seconds from Ethereum, Solana, Base, Arbitrum, Polygon, Avalanche, and BNB Chain. Extremely low fee, only 0.69 USD per transaction. Bridge your assets to Monad network instantly." />
14+
<meta name="keywords"
15+
content="monad bridge, monad blockchain, cross-chain bridge, fastest bridge to monad, monad day one, monad support, blockchain bridge, crypto bridge, ethereum to monad, solana to monad, base to monad, arbitrum bridge, polygon bridge, avalanche bridge, bnb bridge, bnb chain bridge, cross-chain transfer, monad network, monad crypto, bridge to monad, monad launch, monad day 1" />
16+
<meta name="author" content="Monrail" />
17+
<meta name="robots" content="index, follow" />
18+
<link rel="canonical" href="https://monrail.gg/" />
1419

1520
<!-- Open Graph / Facebook -->
1621
<meta property="og:type" content="website" />
1722
<meta property="og:url" content="https://monrail.gg/" />
18-
<meta property="og:title" content="Monrail - Fastest rail Solana > EVM" />
23+
<meta property="og:title" content="Monrail - Fastest Bridge to MONAD | Day One Support" />
1924
<meta property="og:description"
20-
content="Cross-chain transfers in seconds. Extremely low fee, only 0.69 USD per transaction." />
25+
content="The fastest blockchain bridge to MONAD with day one support. Cross-chain transfers in seconds from multiple networks. Low fees, instant transfers." />
2126
<meta property="og:image" content="https://monrail.gg/social_preview.png" />
27+
<meta property="og:site_name" content="Monrail" />
2228

2329
<!-- Twitter -->
2430
<meta name="twitter:card" content="summary_large_image" />
2531
<meta name="twitter:url" content="https://monrail.gg/" />
26-
<meta name="twitter:title" content="Monrail - Fastest rail Solana > EVM" />
32+
<meta name="twitter:title" content="Monrail - Fastest Bridge to MONAD | Day One Support" />
2733
<meta name="twitter:description"
28-
content="Cross-chain transfers in seconds. Extremely low fee, only 0.69 USD per transaction." />
34+
content="The fastest blockchain bridge to MONAD with day one support. Cross-chain transfers in seconds from multiple networks. Low fees, instant transfers." />
2935
<meta name="twitter:image" content="https://monrail.gg/social_preview.png" />
36+
37+
<!-- Additional SEO Tags -->
38+
<meta name="application-name" content="Monrail Bridge" />
39+
<meta name="theme-color" content="#8B5CF6" />
40+
<meta property="og:locale" content="en_US" />
41+
<meta name="format-detection" content="telephone=no" />
42+
43+
<!-- Schema.org markup for Google+ -->
44+
<meta itemprop="name" content="Monrail - Fastest Bridge to MONAD" />
45+
<meta itemprop="description" content="The fastest blockchain bridge to MONAD with day one support. Cross-chain transfers in seconds." />
46+
<meta itemprop="image" content="https://monrail.gg/social_preview.png" />
3047
</head>
3148

3249
<body>
28.7 KB
71.6 KB
4.52 KB
Lines changed: 1 addition & 0 deletions
61.8 KB
25.1 KB
37.3 KB
35.9 KB

0 commit comments

Comments
 (0)