wagmihub
  • πŸ‘‹Introduction
  • 🚩Problem
  • πŸ’‘Solution
  • βš™οΈFeatures
  • πŸͺ™Token
    • πŸ“ŠTokenomics
    • ⏳Vesting Schedule
    • πŸ› οΈToken Utility
  • ⛓️WAGMI Chain
    • Resources for EVM Development
    • Adding WAGMI Chain
    • Adding WAGMI Chain to MetaMask
    • Hardhat Config for WAGMI chain
    • Wagmi Config for WAGMI chain
    • Do I need WAGMI for gas?
    • Deploy smart contracts
    • Developing the UI
    • Add Network Button Example
    • FAQ
    • Support
  • πŸ—ΊοΈRoadmap
  • πŸ’ΌBusiness model
  • πŸ‘₯Socials
  • πŸ‘¨β€πŸ’»Team
  • 🀝Partners
  • πŸ“œLegal Notice
Powered by GitBook
On this page
  1. WAGMI Chain

Add Network Button Example

PreviousDeveloping the UINextFAQ

Last updated 3 months ago

If you already have WAGMI chain , then you can use hook to have a button to switch to it explicitly in your UI if needed:

  • import {
      useSwitchChain
    } from 'wagmi';
    
    function addNetworkButton() {
      const { chains, switchChain } = useSwitchChain();
    
      let wagmi = chains.filter((c) => c.id == 1313161572);
    
      return (
            <button key={wagmi.id} onClick={() => switchChain({ chainId: wagmi.id })}>
              {wagmi.name}
            </button>
          )
    }

If you just have only WAGMI chain in your Dapp’s config, then you won’t need this as it will be selected automatically from .

⛓️
in your config
useSwitchChain
the Wagmi config