Install dao-node-sdk using yarn:
yarn add DAOWallet/nodejs-sdk.gitOr npm:
npm install DAOWallet/nodejs-sdk.gitImport
import { DaoWallet } from 'dao-node-sdk'Or
const { DaoWallet } = require('dao-node-sdk')For using module need initialed class:
const dw = new DaoWallet('your_api_key', 'your_secret_key');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
}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',
}
}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
}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,
}Method SubAccountCreate create new SubAccount
usage example:
const createdSubAccount = await dw.SubAccountCreate('ETH')Method returns object:
{
account_id: string,
balance: number,
created_at: string
}Method SubAccountList returns all company SubAccounts
usage example:
const list = await dw.SubAccountList()Method returns array:
{
account_id: string,
balance: number,
created_at: string
}[]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
}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/falseimport { 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'
})