Developer Reference
Connecting Your Wallet
Pre-launch
Section
Developer Reference
Documentation category
Type
Guide
Technical reference
Summary
How to add SwssChain to MetaMask manually and programmatically: including wallet_addEthereumChain, wallet_switchEthereumChain, and connection verification.
SWSS Foundation Notice

This documentation is restricted to authorised members of the SWSS Developer Community. Access is granted exclusively through SWSS DevHub, after KYB and SWSS Foundation approval.

All SwssChain GitHub repositories are private. Significant updates are currently deploying across the full SWSS Ecosystem. SDK and API specifications are subject to change at any time in accordance with security requirements and SwssChain Foundation governance decisions.

Join SWSS DevHub →Have a question? Use the Need Help? button below.
SDK Update Notice

SWSS SDK v2.1 is deploying across the ecosystem. API signatures may change during this period. Ensure your integration uses the latest schema from SWSS DevHub.

Article Content

Connecting Your Wallet

SwssChain supports all EVM-compatible wallets. MetaMask is the most widely used and is the recommended starting point for developers. Any wallet that supports custom EVM network addition (including Coinbase Wallet, Rainbow, Trust Wallet, and hardware wallets via MetaMask) works with SwssChain without additional configuration beyond the network parameters below.

Manual MetaMask Setup

To add SwssChain Mainnet to MetaMask manually:

  1. Open MetaMask and click the network selector at the top of the extension.
  2. Click Add Network.
  3. Click Add a network manually at the bottom of the list.
  4. Enter the following mainnet details and click Save.
FieldMainnet ValueTestnet Value
Network NameSwssChain MainnetSwssChain Testnet
RPC URLObtain from SWSS DevHubObtain from SWSS DevHub
Chain ID122605122606
Currency SymbolSWSSSWSS
Block Explorer URLhttps://swssscan.swss.iohttps://swssscan.swss.io/testnet

RPC URLs for both mainnet and testnet are available to registered developers at SWSS DevHub. Testnet RPC access is provided free to all registered DevHub accounts.

Programmatic Network Addition

To add SwssChain to MetaMask programmatically from a web application (for example, as part of a "Connect Wallet" flow) use wallet_addEthereumChain:

const SWSSCHAIN_MAINNET = {
  chainId: '0x1DEED',
  chainName: 'SwssChain Mainnet',
  nativeCurrency: {
    name: 'SWSS Coin',
    symbol: 'SWSS',
    decimals: 18
  },
  rpcUrls: [process.env.NEXT_PUBLIC_SWSSCHAIN_RPC],
  blockExplorerUrls: ['https://swssscan.swss.io']
};

async function addSwssChainToWallet() {
  try {
    await window.ethereum.request({
      method: 'wallet_addEthereumChain',
      params: [SWSSCHAIN_MAINNET]
    });
  } catch (error) {
    console.error('Failed to add SwssChain:', error);
  }
}

Switching Networks Programmatically

If the user already has SwssChain added but is on a different network, use wallet_switchEthereumChain:

async function switchToSwssChain() {
  try {
    await window.ethereum.request({
      method: 'wallet_switchEthereumChain',
      params: [{ chainId: '0x1DEED' }]
    });
  } catch (error) {
    // Error code 4902 means chain not added yet
    if (error.code === 4902) {
      await addSwssChainToWallet();
    }
  }
}

Verifying the Connection

After connecting, verify that the user is on SwssChain Mainnet by checking the chain ID. The expected value is 122605n (BigInt) when using ethers.js v6:

import { ethers } from 'ethers';

async function verifySwssChainConnection() {
  const provider = new ethers.BrowserProvider(window.ethereum);
  const network = await provider.getNetwork();

  if (network.chainId !== 122605n) {
    throw new Error(`Wrong network. Expected SwssChain (122605), got ${network.chainId}`);
  }

  console.log('Connected to SwssChain Mainnet');
  return provider;
}

Next Steps

Frequently Asked Questions
6 questions
Which wallets work with SwssChain?

Any wallet supporting custom EVM network addition, including hardware wallets through a compatible interface.

Where does the RPC URL for my wallet come from?

Your issued SWSS DevHub configuration. It is not published in this documentation.

What is error code 4902?

The chain is not yet added to the wallet. Call wallet_addEthereumChain first, then retry the switch.

Can I add the network programmatically?

Yes, with wallet_addEthereumChain. Read the RPC URL from your environment rather than embedding it in client-side code.

Why does my wallet show a different currency?

The symbol is SWSS with 18 decimals. A wallet showing anything else has the wrong network configuration saved.

Do mainnet and testnet use the same explorer?

Separate hosts, the mainnet explorer and its testnet counterpart. Configure the one matching the chain id you added.