1.1.6 • Published 3 years ago

@hightall/dapp-lib v1.1.6

Weekly downloads
-
License
Apache2.0
Repository
-
Last release
3 years ago

Dapp Library

Quick Start

npm i @hightall/dapp-lib

Features

support multiple wallet client:

  1. metamask
  2. walletconnect

Examples

MetaMask

import Dapp from '@hightall/dapp-lib'

const options = {
    extension: 'MetaMask'
}
const dapp = new Dapp(options);
try {
    await dapp.enableBrowserExtension('test');
} catch (e) {
    console.log(e);
}
if (dapp.currentAccount && dapp.currentAccount.address) {
    window.dapp = dapp;
    localStorage.setItem('connect-method', connectMethod);
    const balance = await dapp.getBalance(dapp.currentAccount.address, window.racaAddress, v2Abi, 18);
    localStorage.setItem('balance', balance)
    window.location.reload();
}

Wallet Connect

import Dapp from '@hightall/dapp-lib'

const options = {
    extension: 'WalletConnect',
    providerOptions: {
        rpc: {
            97: 'https://data-seed-prebsc-2-s3.binance.org:8545/',
            56: 'https://bsc-dataseed.binance.org/'
        },
        chainId: window.networkEnv === 'main' ? 56 : 97
    }
}
const dapp = new Dapp(options);
try {
    await dapp.enableBrowserExtension('test');
} catch (e) {
    console.log(e);
}
if (dapp.currentAccount && dapp.currentAccount.address) {
    window.dapp = dapp;
    localStorage.setItem('connect-method', connectMethod);
    const balance = await dapp.getBalance(dapp.currentAccount.address, window.racaAddress, v2Abi, 18);
    localStorage.setItem('balance', balance)
    window.location.reload();
}

supported wallet constructor options is:

  1. extension: the type of the browser extension name
  2. networks: the networks which is the pool for connect.
  3. providerOptions: this is options for wallet connect, means that which network you will choose.

Sample Code

The sample code github address is: https://github.com/hightall/dapp-buy-example

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago