Skip to main content

Overview

GweAI uses Wagmi for Ethereum wallet connections and blockchain interactions. The configuration includes automatic RPC fallback, multiple wallet connectors, and retry logic for reliable connectivity.

Configuration

The Wagmi configuration is exported from wagmi.config.ts:
wagmi.config.ts
import { http, createConfig, fallback } from 'wagmi';
import { baseSepolia } from 'wagmi/chains';
import { injected, coinbaseWallet, walletConnect } from 'wagmi/connectors';

const BASE_SEPOLIA_RPCS = [
  'https://base-sepolia.g.alchemy.com/v2/-mGklZw8tTiO9fg9sRGQP',
  'https://base-sepolia.blockpi.network/v1/rpc/public',
  'https://base-sepolia-rpc.publicnode.com',
];

export const wagmiConfig = createConfig({
  chains: [baseSepolia],
  connectors: [
    injected(),
    coinbaseWallet({
      appName: 'GweAI',
      preference: 'smartWalletOnly',
    }),
    walletConnect({
      projectId: '3fbb6bba6f1de962d911bb5b5c9ddd26',
      metadata: {
        name: 'GweAI',
        description: 'AI-Powered DeFi Trading Platform',
        url: 'https://gweai.com',
        icons: ['https://gweai.com/icon.png'],
      },
      showQrModal: true,
    }),
  ],
  transports: {
    [baseSepolia.id]: fallback(
      BASE_SEPOLIA_RPCS.map(url => http(url, {
        timeout: 10000,
        retryCount: 3,
        retryDelay: 150,
      }))
    ),
  },
});

Supported Chains

chains
Chain[]
default:"[baseSepolia]"
Currently configured for Base Sepolia testnet (Chain ID: 84532)

Wallet Connectors

Injected Connector

Supports browser extension wallets:
import { injected } from 'wagmi/connectors';

const connector = injected();
Supported Wallets:
  • MetaMask
  • Brave Wallet
  • Rabby Wallet
  • Any EIP-1193 compatible wallet

Coinbase Wallet

Configured for Coinbase Smart Wallet (embedded wallet experience):
appName
string
required
Application name displayed in Coinbase Wallet (set to "GweAI")
preference
string
default:"smartWalletOnly"
Wallet type preference. Set to smartWalletOnly for embedded wallet experience
import { coinbaseWallet } from 'wagmi/connectors';

const connector = coinbaseWallet({
  appName: 'GweAI',
  preference: 'smartWalletOnly',
});

WalletConnect

Enables connection to 300+ mobile and desktop wallets:
projectId
string
required
WalletConnect Cloud project ID for relay service
metadata.name
string
required
Application name displayed in WalletConnect modal
metadata.description
string
required
Application description shown to users
metadata.url
string
required
Application website URL
metadata.icons
string[]
required
Array of icon URLs for branding
showQrModal
boolean
default:"true"
Display QR code modal for mobile wallet connections
import { walletConnect } from 'wagmi/connectors';

const connector = walletConnect({
  projectId: '3fbb6bba6f1de962d911bb5b5c9ddd26',
  metadata: {
    name: 'GweAI',
    description: 'AI-Powered DeFi Trading Platform',
    url: 'https://gweai.com',
    icons: ['https://gweai.com/icon.png'],
  },
  showQrModal: true,
});

Transport Configuration

Fallback Transport

The configuration uses Wagmi’s fallback transport for automatic RPC failover:
timeout
number
default:"10000"
Request timeout in milliseconds (10 seconds)
retryCount
number
default:"3"
Number of retry attempts before moving to next RPC
retryDelay
number
default:"150"
Delay between retry attempts in milliseconds

RPC Endpoints

The transport uses multiple RPC providers in priority order:
1

Alchemy (Primary)

https://base-sepolia.g.alchemy.com/v2/-mGklZw8tTiO9fg9sRGQPBest rate limits and reliability
2

BlockPI (Secondary)

https://base-sepolia.blockpi.network/v1/rpc/publicPublic endpoint with 10M requests/day
3

PublicNode (Tertiary)

https://base-sepolia-rpc.publicnode.comCommunity-run fallback endpoint
Base Sepolia’s official RPC (https://sepolia.base.org) was removed due to aggressive rate limiting causing 403 errors. The fallback strategy provides 99.9% uptime.

Usage Examples

Initialize Wagmi Config

import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { wagmiConfig } from './wagmi.config';

const queryClient = new QueryClient();

function App() {
  return (
    <WagmiProvider config={wagmiConfig}>
      <QueryClientProvider client={queryClient}>
        {/* Your app components */}
      </QueryClientProvider>
    </WagmiProvider>
  );
}

Type Definitions

import type { Config } from 'wagmi';

export const wagmiConfig: Config;

RPC Providers

Learn about RPC fallback strategy and caching

Contract Addresses

Verified contract addresses on Base Sepolia

Best Practices

Production Deployment: Replace the demo Alchemy API key with your own production key from alchemy.com for higher rate limits.
The fallback transport automatically switches between RPCs if one fails, providing resilient connectivity without manual intervention.

Build docs developers (and LLMs) love