amaryfilo / connect-wallet

Connect Crypto Wallet by using CoinbaseWallet (WalletLink), KardiaChain, MetaMask browser extentions or mobile application and WalletConnect service by scanning Wallet Qr-code.
MIT License
19 stars 11 forks source link

feat(chains): add Fantom chain #9

Closed Kamikozz closed 2 years ago

Kamikozz commented 2 years ago

https://docs.fantom.foundation/tutorials/set-up-metamask

Network Name: Fantom Opera RPC Url: https://rpc.ftm.tools/ ChainID: 250 Symbol: FTM Block Explorer URL: https://ftmscan.com/

https://docs.fantom.foundation/tutorials/set-up-metamask-testnet

Network Name: Fantom testnet New RPC Url: https://rpc.testnet.fantom.network/ ChainID: 0xfa2 Symbol: FTM

amaryfilo commented 2 years ago

Greetings! Thank you @Kamikozz for your Pull Request and interest in this package.


Do you use addChains method? With this method you can add custom chains to your project. Use this example structure in your project to add method:

import { ConnectWallet } from '@amfi/connect-wallet';

const connectWallet = new ConnectWallet();
const chains = [
    {
      name: 'fantom',
      chainID: 250,
      hex: '0xfa',
    },
    {
      name: 'fantom-testnet',
      chainID: 4002,
      hex: '0xfa2',
    }
  ];

// Add chains
connectWallet.addChains(chains);
// Init connect
connectWallet.connect(provider, network, settings).then(
  (connected: boolean) => console.log('connect wallet: ', connected),
  (err: any) => console.log('connect wallet error: ', err)
);
Kamikozz commented 2 years ago

@amaryfilo Thanks for advice! I've used this method to extend the library's default chains. Works perfectly!