Quickstart
yarn add depay-crypto-wallets
or
npm install --save depay-crypto-wallets
import { getWallet } from 'depay-crypto-wallets'
let wallet = getWallet();
wallet.name
Support
This library supports the following blockchains:
This library supports the following wallets:
Functionalities
Get wallet name
name:string
: Returns the name of the wallet.
let wallet = getWallet();
wallet.name
Returns 'unknown'
if there is a wallet but type is unknown. Returns undefined
if no wallet was found at all.
Get wallet logo
logo:string
: Returns the logo of the wallet as PNG base64-encoded.
let wallet = getWallet();
wallet.logo
Can return placeholder images if there is a wallet but type is unknown. Returns undefined
if no wallet was found at all.
Get connected account
async account():string
: Gets the currently connected and active account (without prompting a connect screen). Returns undefined
if no account is connected.
let wallet = getWallet();
await wallet.account()
Get connected accounts
async accounts():string
: Gets all conncetd accounts (without prompting a connect screen). Returns []
if no account is connected.
let wallet = getWallet();
await wallet.accounts()
Connect an account
async connect():string
: Connets accounts. Potentially opens wallet connect screen. Provides connected accounts in async return.
let wallet = getWallet();
await wallet.connect()
Receive supported blockchains
blockchains:Array
: Array containing the names of supported blockchains
let wallet = getWallet();
wallet.name
wallet.blockchains
Receive wallet events
on(string, function):undefined
: Register a callback function for given events.
let wallet = getWallet();
wallet.on('account', (newAccount)=>{
doSomething(newAccount)
})
Events
on('account', (newAccount)=>{})
: Triggers when user changes the connected/active wallet account.
on('accounts', (newAccounts)=>{})
: Triggers when user changes any connected wallet account.
on('network', (newNetwork)=>{})
: Triggers when user changes network of the connected wallet.
Assets
Retrieves all assets of the connected crypto wallet account for all supported blockchains at once.
This requires you to have a DePay PRO apiKey.
import { getWallet, setApiKey } from 'depay-crypto-wallets'
setApiKey('MYAPIKEY')
let wallet = getWallet()
let assets = await wallet.assets()
Also allows you to retrieve assets only for a given blockchain:
let assets = await wallet.assets('bsc')
Development
Get started
yarn install
yarn start
Release
npm publish