1.0.1 • Published 2 years ago

@cuonghx.gu-tech/wallet-detector v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Overview

@gusdk/wallet-detector written by vanilla-js support detects the installed wallet and connects your website to your wallet

Getting started

Install package

  npm install @gusdk/wallet-detector

Usage

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting Started</title>
  </head>
  <body>
   <script src="../lib/index.js">
   </script>
   <script>
    const sdk = new GUWalletDetector()
    sdk.activate()
  </script>
  </body>
</html>

Functionality

activate

  • initialize connection to target network

connect to current network injected to browser

  const sdk = new GUWalletDetector()
  sdk.activate()

switch network and connect

  const sdk = new GUWalletDetector()
  sdk.activate(99999) // G.U.Sandbox chain has networkId: 99999

add new network and connect

  const sdk = new GUWalletDetector()
  sdk.activate({
    chainId: 99999,
    chainName: "G.U.Sandbox Chain",
    nativeCurrency: {
      name: "GU Sandbox Token",
      symbol: "GTH",
      decimals: 18,
    }
    blockExplorerUrls: ["https://sandbox1.japanopenchain.org/tx"],
    rpcUrls: ["https://sandbox1.japanopenchain.org:8545"],
    iconUrls: []
  })

watchAsset

  • implement eip-747
  const sdk = new GUWalletDetector()
  sdk.watchAsset({
    address,
    symbol,
    decimals,
    image
  })

getChainId

  • get current chainId
  sdk.getChainId()

getAccounts

  • get current connected list account
  sdk.getAccounts()

getIsActivating

  • get activating state
  sdk.getIsActivating()

getAccount

  • get current connected default account - accounts0
  sdk.getAccount()

getIsActive

  • get activate state
  sdk.getIsActive()

getProvider

  • get current connected provider
  sdk.getProvider()
1.0.1

2 years ago

1.0.0

2 years ago