npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bitsoft-network/cashier-coinbase

v1.0.5

Published

Simplified Coinbase API manager package.

Downloads

6

Readme

cashier-coinbase

Simplified Coinbase API manager package.

Usage

Install the package by typing npm i @bitsoft-network/cashier-coinbase in your project folder.

Setup

Example:
const CoinbaseCashier = require("@bitsoft-network/cashier-coinbase");

const client = new CoinbaseCashier({
  apiKey: "lamekey",
  apiSecret: "lamesecret",
});

Methods

getCashierAccounts

Get cashier accounts information (BTC, ETH and LTC).

Example:
const accounts = await client.getCashierAccounts();

Parameters

None

Returns

  • Object (AccountsObject)

createDepositAddresses

Create user's deposit addresses (BTC, ETH and LTC)

Example:
const addresses = await client.createDepositAddresses(userId);

Parameters

  • userId (String)

Returns

  • Object (AddressesObject)

createNewWithdraw

Create a new withdraw. Amount must be in cryptocurrency (max 4 decimal places). Transaction ID is to ensure every transaction is unique and only executed once.

Example:
const withdraw = await client.createNewWithdraw(
  currency,
  amount,
  toAddress,
  transactionId
);

Parameters

  • currency (String [ BTC | ETH | LTC ])
  • amount (String)
  • toAddress (String)
  • transactionId (String)

Returns

  • Object (WithdrawObject)

getExchangeRate

Get exchange rate for two currencies. Return value will contain exchange rate for one unit of currency.

Example:
const rate = await client.getExchangeRate(currency, toCurrency);
Example 2:
const rate = await client.getExchangeRate("BTC", "EUR"); // 35409.37

Parameters

  • currency (String)
  • toCurrency (String)

Returns

  • Object (RateObject)

validateNotification

Validate incoming IPN (Instant Payment Notification).

Example:
const valid = await client.validateNotification(body, signature);

Parameters

  • body (ExpressJsRequest, Object)
  • signature (String)

Returns

  • Boolean

Objects

ConfigObject

Object which holds all configuration values.

Example

const config = {
  // Coinbase API key
  apiKey: "lamekey",

  // Coinbase API secret
  apiSecret: "lamesecret",

  // API version to use. Default
  // version is: "2022-01-30"
  apiVersion: "",

  // Whether or not to show debug
  // messages
  debug: false,
};

AccountsObject

Stores the Coinbase accounts used by cashier

Example

{
  BTC: {
    id: "...",
    name: "BTC Wallet",
    primary: true,
    type: "wallet",
    currency: {
      code: "BTC",
      name: "Bitcoin",
      color: "#F7931A",
      sort_index: 100,
      exponent: 8,
      type: "crypto",
      address_regex: "^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{59}))$",
      asset_id: "...",
      slug: "bitcoin"
    },
    balance: { "amount": "0.00000000", "currency": "BTC" },
    created_at: "2018-08-28T00:00:00Z",
    updated_at: "2018-08-28T00:00:00Z",
    resource: "account",
    resource_path: "/v2/accounts/...",
    allow_deposits: true,
    allow_withdrawals: true
  },
  ETH: { ... },
  LTC: { ... }
}

AddressesObject

Newly created addresses from Coinbase API.

Example

{
  BTC: '...btcAddress',
  ETH: '...ethAddress',
  LTC: '...ltcAddress'
}

WithdrawObject

Newly created withdraw from Coinbase API.

Example

{
  id: "...transactionIdFromCoinbase",
  network: {
    status: "unconfirmed",
    hash: "463397c87beddd9a61ade61359a13adc9efea26062191fe07147037bce7f33ed",
    name: "bitcoin"
  }
}

License

MIT <3