1.11.6 • Published 5 years ago

aivia v1.11.6

Weekly downloads
72
License
MIT
Repository
-
Last release
5 years ago

AIVIA JavaScript SDK

GitHub license npm version npm version

JavaScript Wrapper for interaction with AIVIA Protocol.

:white_check_mark: Crypto Hedge Fund Template is supported


Please note that THIS version is running on Ropsten TestNet.

Please DO NOT add your MainNet wallet. You may lose your funds.


How to connect to the Ropsten TestNet with Infura

Register with Infura

You need to register for an Infura Access Token.

Fill out the form and you will receive your access token. Use your access token in url of the HTTP_PROVIDER, like:

  const HTTP_PROVIDER = "https://ropsten.infura.io/v3/0db7ff8aff88e_demo_key"

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 10.0 or higher is required.

  npm install aivia -S

Example

const AIVIA_SDK = require("aivia"); // es6
const AIVIA_SDK = require("aivia/sdk"); // es5

const ENTRY_POINT = "0x0000000000000000000000000000000000000000" // protocol entry point contract address
const HTTP_PROVIDER = "https://ropsten.infura.io/v3/YOUR-ACCESS-TOKEN";
const DEFAULT_GAS_PRICE = 10000000000 // in wei, default value 50000000000 (50 gWei)
const SDK = new AIVIA_SDK(ENTRY_POINT, HTTP_PROVIDER, DEFAULT_GAS_PRICE );

Modules

Asset


SDK.asset.getAuditDBAddress(addressOrSymbol) ⇒ AuditDBAddress

returns AuditDB address

Kind: static method of Asset
Returns: AuditDBAddress - AuditDB address

ParamType
addressOrSymbolstring | address

SDK.asset.getRPCAddress(addressOrSymbol) ⇒ RPCAddress

returns asset RPC address

Kind: static method of Asset
Returns: RPCAddress - RPC address

ParamType
addressOrSymbolstring | address

SDK.asset.getRate(addressOrSymbol) ⇒ rate

returns asset rate by address or symbol

Kind: static method of Asset
Returns: rate - current(last) rate

ParamType
addressOrSymbolstring | address

SDK.asset.updateRate(assetAddress, AUM, checksum, options, callback, estimate) ⇒ event

function to update the price of the asset rate

Kind: static method of Asset
Returns: event - transaction event {rate, auditor}

ParamTypeDescription
assetAddressaddressasset address
AUMnumberproject total aum
checksumstringmd5 checksum
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.asset.NET(addressOrSymbol) ⇒ NET

returns asset NET by address or symbol

Kind: static method of Asset

ParamType
addressOrSymbolstring | address

SDK.asset.getInvestors(addressOrSymbol) ⇒ investors

returns asset investors count by address

Kind: static method of Asset

ParamType
addressOrSymboladdress

SDK.asset.getConfig(assetAddress) ⇒ object

returns config by config address

Kind: static method of Asset
Returns: object - config

ParamType
assetAddressstring | address

AssetsRegistry


SDK.asset.getList() ⇒ Array.<assetsList>

returns assets list array

Kind: static method of AssetsRegistry
Properties

NameType
assetsList.itemobject
item.symbolstring
item.addressstring

SDK.asset.getAssetAddress(symbol) ⇒ address

returns asset address by symbol

Kind: static method of AssetsRegistry
Returns: address - asset address

ParamType
symbolstring

SDK.asset.getAssetSymbol(assetAddress) ⇒ symbol

returns asset symbol by address

Kind: static method of AssetsRegistry
Returns: symbol - asset symbol

ParamType
assetAddressaddress

Project


SDK.project.getConfigAddress(assetAddress) ⇒ address

returns config address

Kind: static method of Project
Returns: address - config address

ParamType
assetAddressaddress

SDK.project.getConfig(configAddress) ⇒ object

returns config by config address

Kind: static method of Project
Returns: object - config

ParamType
configAddressstring | address

SDK.project.update(configAddress, key, value, options, callback, estimate) ⇒ transaction

update project config

Kind: static method of Project

ParamTypeDescription
configAddressaddressasset address that will be sold
keystringfield name
valuenumber | stringnew value
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.project.updatePermissionRule(configAddress, rule, options, callback, estimate) ⇒ transaction

update project permissions rule

Kind: static method of Project

ParamTypeDescription
configAddressaddressasset address that will be sold
ruleboolean
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.project.updatePermission(configAddress, countryID, walletTypes, options, callback, estimate) ⇒ transaction

update project permissions wallet types

Kind: static method of Project

ParamTypeDescription
configAddressaddressasset address that will be sold
countryIDnumbercountry ID
walletTypesarray.<number>wallets types array
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.project.getPermissionsRule(configAddress) ⇒ boolean

returns permissions rule(tru or false)

Kind: static method of Project
Returns: boolean - rule

ParamType
configAddressstring | address

SDK.project.getPermissionsList(configAddress, countryID)

returns permissions rule(tru or false)

Kind: static method of Project
Returns{array.<number>}: wallets types array

ParamTypeDescription
configAddressstring | address
countryIDnumberID of country

Deploy


SDK.project.deploy(type, params, options, callback, estimate) ⇒ components

deploy project

Kind: static method of Deploy
Returns: components - deployed project components

ParamTypeDescription
typenumberproject type ID
paramsobject
params.projectNamestringmaximum length 32 characters
params.tokenDetailsobject{tokenName, tokenSymbol, initialPrice, maxTokens, maxInvestors}
params.tokenDetails.tokenNamestringmaximum length 32 characters
params.tokenDetails.tokenSymbolstringmaximum length 32 characters
params.tokenDetails.initialPricenumber
params.tokenDetails.maxTokensnumber
params.tokenDetails.maxInvestorsnumbermaximum number of investors, if equal to "0" then there are no restrictions
params.feesobject{platformFee, entryFee, exitFee}
params.fees.platformFeenumberindicate in percent
params.fees.entryFeenumberindicate in percent
params.fees.exitFeenumberindicate in percent
params.custodianaddresscustodian wallet address
params.permissionsobject{countries, walletTypes, rule}
params.permissions.countriesarray.<number>
params.permissions.walletTypesarray.<number>
params.permissions.ruleboolean
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
callbackfunctionfunction(hash)
estimatebooleanis need estimate

ERC20


SDK.asset.getBalance(wallet, assetAddress) ⇒ balance

returns asset balance by assetAddress or ETH balance

Kind: static method of ERC20

ParamType
walletaddress
assetAddressAddress

SDK.asset.totalSupply(assetAddress) ⇒ totalSupply

returns asset totalSupply

Kind: static method of ERC20

ParamType
assetAddressaddress

SDK.asset.allowance(assetAddress, owner, spender) ⇒ allowance

returns amount approved by owner to spender

Kind: static method of ERC20

ParamType
assetAddressaddress
owneraddress
spenderaddress

SDK.asset.approve(assetAddress, spender, value, options, callback, estimate) ⇒ event

allows spender to manage a certain amount of assets

Kind: static method of ERC20
Returns: event - transaction event {from, to, value}

ParamTypeDescription
assetAddressaddressasset address
spenderaddressspender wallet address
valuenumberamount of asset
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.asset.transfer(to, value, assetAddress, options, callback, estimate) ⇒ event

transfer ERC20 asset value to other address

Kind: static method of ERC20
Returns: event - transaction event {from, to, value}

ParamTypeDescription
toaddresswallet address
valuenumberamount of asset
assetAddressaddressasset address
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.asset.transferETH(to, value, options, callback, estimate) ⇒ event

transfer ETH value to other address

Kind: static method of ERC20
Returns: event - transaction event {from, to, value}

ParamTypeDescription
toaddresswallet address
valuenumberamount of asset
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.asset.mint(value, to, assetAddress, options, callback, estimate) ⇒ event

mint asset value to other wallet from contract owner

Kind: static method of ERC20
Returns: event - transaction event {from, to, value}

ParamTypeDescription
valuenumberamount of asset
toaddresswallet address
assetAddressaddressasset address
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

Platform


SDK.platform.getPlatformWallet() ⇒ address

returns platform wallet address

Kind: static method of Platform


SDK.platform.getPlatformToken() ⇒ address

returns platform token address

Kind: static method of Platform


Buy/Sell


SDK.trade.checkBeforeBuy(value, assetAddress, currencyAddress, from) ⇒ true | error

the method by which you can first check the parameters before buy

Kind: static method of Buy/Sell
Returns: true | error - ;

ParamTypeDescription
valuenumberthe amount of the asset that will be exchanged for the assets you want to buy
assetAddressaddressasset address that will be bought
currencyAddressaddressaddress of the asset to be sold
fromaddresswallet address

SDK.trade.buyAsset(value, assetAddress, currencyAddress, options, callback, estimate) ⇒ event

purchase of tokens

Kind: static method of Buy/Sell
Returns: event - transaction event {spend, received, fees: { manager, platform } }

ParamTypeDescription
valuenumberthe amount of the asset that will be exchanged for the assets you want to buy
assetAddressaddressasset address that will be bought
currencyAddressaddressaddress of the asset to be sold
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.trade.checkBeforeSell(value, assetAddress, options) ⇒ true | error

the method by which you can first check the parameters before sell

Kind: static method of Buy/Sell
Returns: true | error - ;

ParamTypeDescription
valuenumberthe amount of the asset that will be sold
assetAddressaddressasset address that will be sold
optionsobject
options.addressaddresswallet address

SDK.trade.sellAsset(value, assetAddress, options, callback, estimate) ⇒ event

sale of tokens

Kind: static method of Buy/Sell
Returns: event - transaction event {spend, received, fees: { manager, platform } }

ParamTypeDescription
valuenumberthe amount of the asset that will be sold
assetAddressaddressasset address that will be sold
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.trade.estimate(value, assetAddress, currencyAddress) ⇒ estimate

Kind: static method of Buy/Sell
Returns: estimate - ;

ParamTypeDescription
valuenumberthe amount of the asset
assetAddressaddressasset address
currencyAddressaddresscurrency address

Currency


SDK.platform.currency.getList() ⇒ Array.<currenciesList>

returns platform currencies list

Kind: static method of Currency
Properties

NameType
currenciesList.itemobject
item.symbolstring
item.addressstring
item.ratenumber

SDK.platform.currency.getRate(addressOrSymbol) ⇒ rate

returns currency rate by address or symbol

Kind: static method of Currency
Returns: rate - - rate of currency

ParamType
addressOrSymbolstring | address

SDK.platform.currency.getAddress(symbol) ⇒ address

returns currency address by symbol

Kind: static method of Currency
Returns: address - currency address

ParamType
symbolstring

SDK.platform.currency.getSymbol(currencyAddress) ⇒ symbol

returns currency symbol by address

Kind: static method of Currency
Returns: symbol - currency symbol

ParamType
currencyAddressaddress

TPLRegistry


SDK.auditor.addUser(userAddress, countryID, walletType, expirationDate, options, callback, estimate) ⇒ event

add or update user

Kind: static method of TPLRegistry
Returns: event - transaction event {eventName, address}

ParamTypeDefaultDescription
userAddressaddressuser wallet address
countryIDnumbercounty ID
walletTypenumberwallet type ID
expirationDatenumber0expiration date
optionsobject
options.addressaddresswallet address
options.privateKeystringprivate key
options.gasPricenumbergas price
options.gasLimitnumbergas limit
options.noncenumbernonce of transaction
callbackfunctionfunction(hash)
estimatebooleanis need estimate

SDK.auditor.getUserDetails(userAddress) ⇒ object

returns user details by address

Kind: static method of TPLRegistry
Returns: object - userDetails

ParamType
userAddressaddress

Properties

NameType
userDetails.addressaddress
userDetails.countrynumber
userDetails.walletTypenumber
userDetails.expirationDatenumber

SDK.auditor.getUsersList() ⇒ Array.<userList>

returns user list list

Kind: static method of TPLRegistry
Properties

NameType
userList.userobject
user.addressaddress
user.countrynumber
user.walletTypenumber
user.expirationDatenumber

utils


SDK.utils.toHex(string) ⇒ hex

convert string to hex

Kind: static method of utils
Returns: hex - the resulting HEX string;

ParamType
stringstring

SDK.utils.toWei(value) ⇒ value

converts any value value into wei

Kind: static method of utils

ParamType
valuenumber

SDK.utils.fromWei(value) ⇒ value

converts any value from wei

Kind: static method of utils
Returns: value - ;

ParamType
valuenumber

SDK.utils.isAddress(address) ⇒ boolean

check if a given string is a valid Ethereum address

Kind: static method of utils
Returns: boolean - status;

ParamType
addressaddress

SDK.utils.toUtf8(hex) ⇒ string

converts any value from hex to string

Kind: static method of utils
Returns: string - ;

ParamType
hexstring

SDK.utils.toFixed(value, digits) ⇒ value

formats a number using fixed-point notation

Kind: static method of utils

ParamTypeDefaultDescription
valuenumber
digitsnumber5digits it's number of digits to appear after the decimal point;

SDK.utils.numberToHex(value, inWei) ⇒ string

covert number to hex

Kind: static method of utils
Returns: string - number;

ParamTypeDefault
valuevalue
inWeibooleanfalse

SDK.utils.BN(value) ⇒ BN

covert number to BN

Kind: static method of utils
Returns: BN - BN;

ParamType
valuevalue

1.11.6

5 years ago

1.11.5

5 years ago

1.11.4

5 years ago

1.11.3

5 years ago

1.11.2

5 years ago

1.11.1

5 years ago

1.11.0

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.7

5 years ago

1.8.6

5 years ago

1.8.5

5 years ago

1.8.4

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago