Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.teqoin.io/llms.txt

Use this file to discover all available pages before exploring further.

Integrate a wallet

Wallet integration is the minimum requirement for any dapp that needs user signatures or transactions. This guide shows a simple browser-wallet integration flow for TeQoin.

TeQoin network details

Use these values when adding the chain:
FieldValue
Network nameTeQoin L2
RPC URLhttps://rpc.teqoin.io
Chain ID420377
Chain ID hex0x66A19
Currency symbolETH

Step 1: Detect a wallet

if (!window.ethereum) {
  throw new Error('No injected wallet was found');
}

Step 2: Request access

const accounts = await window.ethereum.request({
  method: 'eth_requestAccounts',
});

const activeAccount = accounts[0];

Step 3: Add or switch the network

const teqoinNetwork = {
  chainId: '0x66A19',
  chainName: 'TeQoin L2',
  rpcUrls: ['https://rpc.teqoin.io'],
  nativeCurrency: {
    name: 'Ether',
    symbol: 'ETH',
    decimals: 18,
  },
};

async function connectToTeQoin() {
  try {
    await window.ethereum.request({
      method: 'wallet_switchEthereumChain',
      params: [{ chainId: teqoinNetwork.chainId }],
    });
  } catch (error) {
    if (error.code === 4902) {
      await window.ethereum.request({
        method: 'wallet_addEthereumChain',
        params: [teqoinNetwork],
      });
      return;
    }

    throw error;
  }
}

Step 4: Build an ethers provider

import { ethers } from 'ethers';

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const address = await signer.getAddress();

Step 5: Listen for wallet changes

window.ethereum.on('accountsChanged', (accounts) => {
  console.log('accountsChanged', accounts);
});

window.ethereum.on('chainChanged', (chainId) => {
  console.log('chainChanged', chainId);
  window.location.reload();
});
Use this flow in production:
  1. Detect the wallet on page load.
  2. Ask the user to connect only when they start an action.
  3. Verify the chain before every write transaction.
  4. Show clear errors for rejected signatures and wrong-network states.

Security notes

  • Never ask users to paste private keys into your app.
  • Never store private keys in frontend code.
  • Revalidate the selected account before sending a transaction.

Where to go next