Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

depay-crypto-wallets

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depay-crypto-wallets

One-Stop-Shop JavaScript library to integrate various crypto wallets and multiple blockchains at once with a single interface.

  • 2.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by700%
Maintainers
1
Weekly downloads
 
Created
Source

Quickstart

yarn add depay-crypto-wallets

or

npm install --save depay-crypto-wallets
import { getWallet } from 'depay-crypto-wallets'

let wallet = getWallet();
wallet.name // MetaMask

Support

This library supports the following blockchains:

  • Ethereum
  • Binance Smart Chain

This library supports the following wallets:

Functionalities

Get wallet name

name:string: Returns the name of the wallet.

let wallet = getWallet();
wallet.name // 'MetaMask'

Returns 'unknown' if there is a wallet but type is unknown. Returns undefined if no wallet was found at all.

logo:string: Returns the logo of the wallet as PNG base64-encoded.

let wallet = getWallet();
wallet.logo // 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAclBMVEVHcEyBTif0snbypF3nhijulD7cq4Hv1b/wrW3dvqSieVvWyL2PXjvJuazndgD5hQB3PQ/PYQDkdADCrp3YwrPsegAVFRZyOg7ZawDzgQD/iQAeMklxNQMMDQ+3XwiLRw2hVAyCdmxPQz7dqoAyKiSgkoj9gMFYAAAADnRSTlMA8X2g78dnGzZPp57O1Hi2/psAAApFSURBVHja7Z2LVqM6FIZ7pUUrtbQRqEyLHX3/Vzy5soHcICSd41r5z3EcFUL+7m/vXKDOIioqKioqKioqKioqKioqKioqKioqKurXKnlJd4t/rB3uxGKuXur7Zr1f/EPt15t7/TK3ld2yKN5vaLv6R2HZrbbo9l4Uy7nXT+t33EyTZ5ttsls8Wbtku8nypihwH9LZZL1jFfcS5fmTEcNI5XlW3gvSg/plNlnvRASvDDf7NMQwUuR6GCvegeVuNllYDC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LOEXbTKvCAAAAAElFTkSuQmCC'

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() // '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B'

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() // ['0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B']

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() // ['0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B']

Receive supported blockchains

blockchains:Array: Array containing the names of supported blockchains

let wallet = getWallet();
wallet.name // MetaMask
wallet.blockchains // ['ethereum', 'bsc']

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()
//[
// {
//   "name": "Dai Stablecoin",
//   "symbol": "DAI",
//   "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
//   "blockchain": "ethereum",
//   "type": "ERC20",
//   "balance": "8007804249707967889272"
// }, {
//   "name": "DePay",
//   "symbol": "DEPAY",
//   "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb",
//   "blockchain": "ethereum",
//   "type": "ERC20",
//   "balance": "212816860003097638129"
// }, {
//   "name": "PancakeSwap Token",
//   "symbol": "CAKE",
//   "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
//   "blockchain": "bsc",
//   "type": "BEP20",
//   "balance": "2221112213212321"
// }
//]

Also allows you to retrieve assets only for a given blockchain:

let assets = await wallet.assets('bsc')
//[
// {
//   "name": "PancakeSwap Token",
//   "symbol": "CAKE",
//   "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
//   "blockchain": "bsc",
//   "type": "BEP20",
//   "balance": "2221112213212321"
// }
//]

Development

Get started

yarn install
yarn start

Release

npm publish

Keywords

FAQs

Package last updated on 16 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc