Giter Club home page Giter Club logo

balance-crypto's Introduction

balance-crypto

Vulnerabilities Version Minified size Downloads GitHub Workflow Status Codecov

Get wallet balance for 5.8K+ cryptocurrencies with a single function.

Comparison to crypto-balances-2:

  • ๐Ÿ” API keys support (for EtherScan and BlockCypher)
  • ๐Ÿ’™ written in TypeScript
  • โšก doesn't depend on request libraries
  • ๐Ÿ“ฆ smaller library size
  • ๐Ÿฆ• Deno and Node.js support

Install

# pnpm
pnpm i balance-crypto
# yarn
yarn add balance-crypto
# npm
npm i balance-crypto

To use the module in Deno import it like this: import { balance } from 'https://deno.land/x/balance_crypto/deno/mod.ts'

Example

Node.js

import { balance } from 'balance-crypto'
import fetch from 'node-fetch'

balance('3PxedDftWBXujWtr7TbWQSiYTsZJoMD8K5', 'BTC', {
  keys: {
    etherscan: process.env.ETHERSCAN_KEY,
    blockcypher: process.env.BLOCKYCPHER_KEY
  },
  verbose: true
}).then((res) => console.log(res))

Deno

import { balance } from 'https://deno.land/x/balance_crypto/deno/mod.ts'

balance('3PxedDftWBXujWtr7TbWQSiYTsZJoMD8K5', 'BTC', {
  keys: {
    etherscan: Deno.env.get('ETHERSCAN_KEY'),
    blockcypher: Deno.env.get('BLOCKYCPHER_KEY')
  },
  verbose: true
}).then((res) => console.log(res))

Result:

{ "balance": 0, "asset": "BTC" }

Supported cryptos

Asset Service API key
ETH, ERC-20 tokens https://etherscan.io โœ”๏ธ
BTC, DASH, LTC, DOGE https://blockcypher.com โœ”๏ธ (optional)
BTC-based tokens https://chainz.cryptoid.info
ADA https://explorer.cardano.org

balance-crypto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

balance-crypto's Issues

doge search

Hello, i am searching doge coin with this :

balance('0xf8e9b725e0de8a9546916861c2904b0eb8805b96', 'DOGE', {
keys: {
etherscan: process.env.ETHERSCAN_KEY,
blockcypher: process.env.BLOCKYCPHER_KEY
},
verbose: true
}).then((res) => console.log(res))

it says every doge address : Error: Invalid address "0xf8e9b725e0de8a9546916861c2904b0eb8805b96" for DOGE

Not working for me

I'm running the example code in README

 npm run test

> [email protected] test
> node --loader ts-node/esm --experimental-specifier-resolution=node node_modules/uvu/bin.js

(node:19362) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19362) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(node:19362) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
test/test.js

  Total:     0
  Passed:    0
  Skipped:   0
  Duration:  0.96ms

file:///home/debian/node_modules/balance-crypto/dist/index.js:5171
        throw new Error(`Invalid address "${addr}" for ${coin}`);
              ^

Error: Invalid address "3PxedDftWBXujWtr7TbWQSiYTsZJoMD8K5" for BTC
    at balance (file:///home/debian/node_modules/balance-crypto/dist/index.js:5171:15)
    at file:///home/debian/node_modules/balance-crypto/test/test.js:4:1
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async Module.run (file:///home/debian/node_modules/balance-crypto/node_modules/uvu/run/index.mjs:9:3)
    at async /home/debian/node_modules/balance-crypto/node_modules/uvu/bin.js:26:5

Node.js v18.19.0

I also tried ETH and added an valid API. It said API invalid. Code broken?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.