Skip to content

DAOWallet/nodejs-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

Install dao-node-sdk using yarn:

yarn add DAOWallet/nodejs-sdk.git

Or npm:

npm install DAOWallet/nodejs-sdk.git

Import

Import

import { DaoWallet } from 'dao-node-sdk'

Or

const { DaoWallet } = require('dao-node-sdk')

Usage

For using module need initialed class:

const dw = new DaoWallet('your_api_key', 'your_secret_key');

Methods

General

AddressesTake

Method AddressesTake returns crypto address by user_id and currency. Usage example:

const address = await dw.AddressesTake('userId any random string less than 128 chars', 'BTC')

Method returns object:

{
  id: number,
  address: string,
  currency: 'BTC' | 'ETH',
  foreign_id: string,
  tag: string
}

CryptoWithdrawal

Method CryptoWithdrawal withraw money from company balance to current address Usage example:

const withdrawalResult = await dw.CryptoWithdrawal('userId', 0.001, 'BTC', 'user_address')

Method returns object:

{
  data: {
    type: 'withdrawal',
    amount: number,
    sender_currency: 'BTC' | 'ETH',
    receiver_currency: 'BTC' | 'ETH',
  }
}

Invoices

InvoiceStatus

Method InvoiceStatus returns invoice`s status by id Usage example:

const invoiceInfo = await dw.InvoiceStatus('invoice-id')

Method returns object:

{
  foreign_id: string,
  addresses: {
    address: string,
    expected_amount: number,
    crypto_currency: 'BTC' | 'ETH',
    rate_usd: number,
    rate_eur: number,
  }[],
  client_amount: number,
  client_currency: 'USD' | 'EUR',
  status: 'created' | 'paid' | 'expired' | 'declined',
  expired_at: string,
  paid_at: string,
  paid_currency: 'BTC' | 'ETH',
  paid_tx: string
}

InvoiceCreate

Method InvoiceCreate create new invoice Usage example:

const createdInvoice = await dw.InvoiceCreate(20, 'EUR');

Method returns object:

{
  foreign_id: string,
  addresses: {
    address: string,
    expected_amount: number,
    crypto_currency: 'BTC' | 'ETH',
    rate_usd: number,
    rate_eur: number,
  }[],
  client_amount: number,
  client_currency: 'USD' | 'EUR',
  status: 'created' | 'paid' | 'expired' | 'declined',
  expired_at: string,
  paid_at: string,
  paid_currency: 'BTC' | 'ETH',
  paid_tx: string,
}

SubAccounts

SubAccountCreate

Method SubAccountCreate create new SubAccount usage example:

const createdSubAccount = await dw.SubAccountCreate('ETH')

Method returns object:

  {
    account_id: string,
    balance: number,
    created_at: string
  }

SubAccountList

Method SubAccountList returns all company SubAccounts usage example:

const list = await dw.SubAccountList()

Method returns array:

  {
    account_id: string,
    balance: number,
    created_at: string
  }[]

SubAccountExcahnge

Method SubAccountExcahnge excahnge from/to SubAccount usage example:

const excahngeFromSubAccount = await dw.SubAccountExcahnge({
  from: 'C.111.ETH.ZZZ',
  currency_from: 'ETH',
  currency_to: 'BTC',
  amount: 0.02
})
const excahngeToSubAccount = await dw.SubAccountExcahnge({
  to: 'C.111.ETH.ZZZ',
  currency_from: 'USDT',
  currency_to: 'ETH',
  amount: 15
})

Method returns object:

  {
    amount: number,
    currency: string
  }

SubAccountWithdrawal

Method SubAccountWithdrawal withdraw crypto from SubAccounts usage example:

const withdrawal = await dw.SubAccountWithdrawal({
  accountId: 'C.111.ETH.ZZZ',
  amount: 0.001,
  address: 'some_eth_address'
})

Method returns boolean value:

  true/false

Total usage example

import { ECryptoCurrency, EFiatCurrencyName } from './src/DaoWallet.interface';
import { DaoWallet } from './src/DaoWallet'
const { BTC, ETH } = ECryptoCurrency;
const { EUR, USD } = EFiatCurrencyName;

const dw = new DaoWallet('your_api_key', 'your_secret_key');
const takeAddressResult = await dw.AddressesTake('userId', BTC);

const { address } = takeAddressResult.data;

const withdrawalResult = await dw.CryptoWithdrawal('userId', 0.001, BTC, 'user_address');

const invoiceInfo = await dw.InvoiceStatus('invoice-id');
const createdInvoice = await dw.InvoiceCreate(20, EUR);

const createdSubAccount = await dw.SubAccountCreate(ETH)
const list = await dw.SubAccountList()

const excahngeToSubAccount = await dw.SubAccountExcahnge({
  to: 'C.111.ETH.ZZZ',
  currency_from: 'USDT',
  currency_to: 'ETH',
  amount: 15
})

const excahngeFromSubAccount = await dw.SubAccountExcahnge({
  from: 'C.111.ETH.ZZZ',
  currency_from: 'ETH',
  currency_to: 'BTC',
  amount: 0.02
})

const withdrawal = await dw.SubAccountWithdrawal({
  accountId: 'C.111.ETH.ZZZ',
  amount: 0.001,
  address: 'some_eth_address'
})

About

DAOWallet SDK for nodejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors