aivia v1.11.6
AIVIA JavaScript SDK
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
- Asset
- .getAuditDBAddress(addressOrSymbol) ⇒ AuditDBAddress
- .getRPCAddress(addressOrSymbol) ⇒ RPCAddress
- .getRate(addressOrSymbol) ⇒ rate
- .updateRate(assetAddress, AUM, checksum, options, callback, estimate) ⇒ event
- .NET(addressOrSymbol) ⇒ NET
- .getInvestors(addressOrSymbol) ⇒ investors
- .getConfig(assetAddress) ⇒ object
SDK.asset.getAuditDBAddress(addressOrSymbol) ⇒ AuditDBAddress
returns AuditDB address
Kind: static method of Asset
Returns: AuditDBAddress - AuditDB address
Param | Type |
---|---|
addressOrSymbol | string | address |
SDK.asset.getRPCAddress(addressOrSymbol) ⇒ RPCAddress
returns asset RPC address
Kind: static method of Asset
Returns: RPCAddress - RPC address
Param | Type |
---|---|
addressOrSymbol | string | address |
SDK.asset.getRate(addressOrSymbol) ⇒ rate
returns asset rate by address or symbol
Kind: static method of Asset
Returns: rate - current(last) rate
Param | Type |
---|---|
addressOrSymbol | string | 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}
Param | Type | Description |
---|---|---|
assetAddress | address | asset address |
AUM | number | project total aum |
checksum | string | md5 checksum |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
SDK.asset.NET(addressOrSymbol) ⇒ NET
returns asset NET by address or symbol
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | string | address |
SDK.asset.getInvestors(addressOrSymbol) ⇒ investors
returns asset investors count by address
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | address |
SDK.asset.getConfig(assetAddress) ⇒ object
returns config by config address
Kind: static method of Asset
Returns: object - config
Param | Type |
---|---|
assetAddress | string | address |
AssetsRegistry
- AssetsRegistry
- .getList() ⇒ Array.<assetsList>
- .getAssetAddress(symbol) ⇒ address
- .getAssetSymbol(assetAddress) ⇒ symbol
SDK.asset.getList() ⇒ Array.<assetsList>
returns assets list array
Kind: static method of AssetsRegistry
Properties
Name | Type |
---|---|
assetsList.item | object |
item.symbol | string |
item.address | string |
SDK.asset.getAssetAddress(symbol) ⇒ address
returns asset address by symbol
Kind: static method of AssetsRegistry
Returns: address - asset address
Param | Type |
---|---|
symbol | string |
SDK.asset.getAssetSymbol(assetAddress) ⇒ symbol
returns asset symbol by address
Kind: static method of AssetsRegistry
Returns: symbol - asset symbol
Param | Type |
---|---|
assetAddress | address |
Project
- Project
- .getConfigAddress(assetAddress) ⇒ address
- .getConfig(configAddress) ⇒ object
- .update(configAddress, key, value, options, callback, estimate) ⇒ transaction
- .updatePermissionRule(configAddress, rule, options, callback, estimate) ⇒ transaction
- .updatePermission(configAddress, countryID, walletTypes, options, callback, estimate) ⇒ transaction
- .getPermissionsRule(configAddress) ⇒ boolean
- .getPermissionsList(configAddress, countryID)
SDK.project.getConfigAddress(assetAddress) ⇒ address
returns config address
Kind: static method of Project
Returns: address - config address
Param | Type |
---|---|
assetAddress | address |
SDK.project.getConfig(configAddress) ⇒ object
returns config by config address
Kind: static method of Project
Returns: object - config
Param | Type |
---|---|
configAddress | string | address |
SDK.project.update(configAddress, key, value, options, callback, estimate) ⇒ transaction
update project config
Kind: static method of Project
Param | Type | Description |
---|---|---|
configAddress | address | asset address that will be sold |
key | string | field name |
value | number | string | new value |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
SDK.project.updatePermissionRule(configAddress, rule, options, callback, estimate) ⇒ transaction
update project permissions rule
Kind: static method of Project
Param | Type | Description |
---|---|---|
configAddress | address | asset address that will be sold |
rule | boolean | |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
SDK.project.updatePermission(configAddress, countryID, walletTypes, options, callback, estimate) ⇒ transaction
update project permissions wallet types
Kind: static method of Project
Param | Type | Description |
---|---|---|
configAddress | address | asset address that will be sold |
countryID | number | country ID |
walletTypes | array.<number> | wallets types array |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
SDK.project.getPermissionsRule(configAddress) ⇒ boolean
returns permissions rule(tru or false)
Kind: static method of Project
Returns: boolean - rule
Param | Type |
---|---|
configAddress | string | address |
SDK.project.getPermissionsList(configAddress, countryID)
returns permissions rule(tru or false)
Kind: static method of Project
Returns{array.<number>}: wallets types array
Param | Type | Description |
---|---|---|
configAddress | string | address | |
countryID | number | ID of country |
Deploy
SDK.project.deploy(type, params, options, callback, estimate) ⇒ components
deploy project
Kind: static method of Deploy
Returns: components - deployed project components
Param | Type | Description |
---|---|---|
type | number | project type ID |
params | object | |
params.projectName | string | maximum length 32 characters |
params.tokenDetails | object | {tokenName, tokenSymbol, initialPrice, maxTokens, maxInvestors} |
params.tokenDetails.tokenName | string | maximum length 32 characters |
params.tokenDetails.tokenSymbol | string | maximum length 32 characters |
params.tokenDetails.initialPrice | number | |
params.tokenDetails.maxTokens | number | |
params.tokenDetails.maxInvestors | number | maximum number of investors, if equal to "0" then there are no restrictions |
params.fees | object | {platformFee, entryFee, exitFee} |
params.fees.platformFee | number | indicate in percent |
params.fees.entryFee | number | indicate in percent |
params.fees.exitFee | number | indicate in percent |
params.custodian | address | custodian wallet address |
params.permissions | object | {countries, walletTypes, rule} |
params.permissions.countries | array.<number> | |
params.permissions.walletTypes | array.<number> | |
params.permissions.rule | boolean | |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
callback | function | function(hash) |
estimate | boolean | is need estimate |
ERC20
- ERC20
- .getBalance(wallet, [assetAddress]) ⇒ balance
- .totalSupply(assetAddress) ⇒ totalSupply
- .allowance(assetAddress, owner, spender) ⇒ allowance
- .approve(assetAddress, spender, value, options, callback, estimate) ⇒ event
- .transfer(to, value, assetAddress, options, callback, estimate) ⇒ event
- .transferETH(to, value, options, callback, estimate) ⇒ event
- .mint(value, to, assetAddress, options, callback, estimate) ⇒ event
SDK.asset.getBalance(wallet, assetAddress) ⇒ balance
returns asset balance by assetAddress or ETH balance
Kind: static method of ERC20
Param | Type |
---|---|
wallet | address |
assetAddress | Address |
SDK.asset.totalSupply(assetAddress) ⇒ totalSupply
returns asset totalSupply
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
SDK.asset.allowance(assetAddress, owner, spender) ⇒ allowance
returns amount approved by owner to spender
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
owner | address |
spender | address |
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}
Param | Type | Description |
---|---|---|
assetAddress | address | asset address |
spender | address | spender wallet address |
value | number | amount of asset |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is 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}
Param | Type | Description |
---|---|---|
to | address | wallet address |
value | number | amount of asset |
assetAddress | address | asset address |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is 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}
Param | Type | Description |
---|---|---|
to | address | wallet address |
value | number | amount of asset |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is 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}
Param | Type | Description |
---|---|---|
value | number | amount of asset |
to | address | wallet address |
assetAddress | address | asset address |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
Platform
- Platform
- .getPlatformWallet() ⇒ address
- .getPlatformToken() ⇒ address
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
- Buy/Sell
- .checkBeforeBuy(value, assetAddress, currencyAddress, from) ⇒ true | error
- .buyAsset(value, assetAddress, currencyAddress, options, callback, estimate) ⇒ event
- .checkBeforeSell(value, assetAddress, options) ⇒ true | error
- .sellAsset(value, assetAddress, options, callback, estimate) ⇒ event
- .estimate(value, assetAddress, [currencyAddress]) ⇒ estimate
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 - ;
Param | Type | Description |
---|---|---|
value | number | the amount of the asset that will be exchanged for the assets you want to buy |
assetAddress | address | asset address that will be bought |
currencyAddress | address | address of the asset to be sold |
from | address | wallet 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 } }
Param | Type | Description |
---|---|---|
value | number | the amount of the asset that will be exchanged for the assets you want to buy |
assetAddress | address | asset address that will be bought |
currencyAddress | address | address of the asset to be sold |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is 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 - ;
Param | Type | Description |
---|---|---|
value | number | the amount of the asset that will be sold |
assetAddress | address | asset address that will be sold |
options | object | |
options.address | address | wallet 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 } }
Param | Type | Description |
---|---|---|
value | number | the amount of the asset that will be sold |
assetAddress | address | asset address that will be sold |
options | object | |
options.address | address | wallet address |
options.privateKey | string | private key |
options.gasPrice | number | gas price |
options.gasLimit | number | gas limit |
options.nonce | number | nonce of transaction |
callback | function | function(hash) |
estimate | boolean | is need estimate |
SDK.trade.estimate(value, assetAddress, currencyAddress) ⇒ estimate
Kind: static method of Buy/Sell
Returns: estimate - ;
Param | Type | Description |
---|---|---|
value | number | the amount of the asset |
assetAddress | address | asset address |
currencyAddress | address | currency address |
Currency
- Currency
- .getList() ⇒ Array.<currenciesList>
- .getRate(addressOrSymbol) ⇒ rate
- .getAddress(symbol) ⇒ address
- .getSymbol(currencyAddress) ⇒ symbol
SDK.platform.currency.getList() ⇒ Array.<currenciesList>
returns platform currencies list
Kind: static method of Currency
Properties
Name | Type |
---|---|
currenciesList.item | object |
item.symbol | string |
item.address | string |
item.rate | number |
SDK.platform.currency.getRate(addressOrSymbol) ⇒ rate
returns currency rate by address or symbol
Kind: static method of Currency
Returns: rate - - rate of currency
Param | Type |
---|---|
addressOrSymbol | string | address |
SDK.platform.currency.getAddress(symbol) ⇒ address
returns currency address by symbol
Kind: static method of Currency
Returns: address - currency address
Param | Type |
---|---|
symbol | string |
SDK.platform.currency.getSymbol(currencyAddress) ⇒ symbol
returns currency symbol by address
Kind: static method of Currency
Returns: symbol - currency symbol
Param | Type |
---|---|
currencyAddress | address |
TPLRegistry
- TPLRegistry
- .addUser(userAddress, countryID, walletType, [expirationDate], options, callback, estimate) ⇒ event
- .getUserDetails(userAddress) ⇒ object
- .getUsersList() ⇒ Array.<userList>
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}
Param | Type | Default | Description |
---|---|---|---|
userAddress | address | user wallet address | |
countryID | number | county ID | |
walletType | number | wallet type ID | |
expirationDate | number | 0 | expiration date |
options | object | ||
options.address | address | wallet address | |
options.privateKey | string | private key | |
options.gasPrice | number | gas price | |
options.gasLimit | number | gas limit | |
options.nonce | number | nonce of transaction | |
callback | function | function(hash) | |
estimate | boolean | is need estimate |
SDK.auditor.getUserDetails(userAddress) ⇒ object
returns user details by address
Kind: static method of TPLRegistry
Returns: object - userDetails
Param | Type |
---|---|
userAddress | address |
Properties
Name | Type |
---|---|
userDetails.address | address |
userDetails.country | number |
userDetails.walletType | number |
userDetails.expirationDate | number |
SDK.auditor.getUsersList() ⇒ Array.<userList>
returns user list list
Kind: static method of TPLRegistry
Properties
Name | Type |
---|---|
userList.user | object |
user.address | address |
user.country | number |
user.walletType | number |
user.expirationDate | number |
utils
- utils
- .toHex(string) ⇒ hex
- .toWei(value) ⇒ value
- .fromWei(value) ⇒ value
- .isAddress(address) ⇒ boolean
- .toUtf8(hex) ⇒ string
- .toFixed(value, [digits]) ⇒ value
- .numberToHex(value, [inWei]) ⇒ string
- .BN(value) ⇒ BN
SDK.utils.toHex(string) ⇒ hex
convert string to hex
Kind: static method of utils
Returns: hex - the resulting HEX string;
Param | Type |
---|---|
string | string |
SDK.utils.toWei(value) ⇒ value
converts any value value into wei
Kind: static method of utils
Param | Type |
---|---|
value | number |
SDK.utils.fromWei(value) ⇒ value
converts any value from wei
Kind: static method of utils
Returns: value - ;
Param | Type |
---|---|
value | number |
SDK.utils.isAddress(address) ⇒ boolean
check if a given string is a valid Ethereum address
Kind: static method of utils
Returns: boolean - status;
Param | Type |
---|---|
address | address |
SDK.utils.toUtf8(hex) ⇒ string
converts any value from hex to string
Kind: static method of utils
Returns: string - ;
Param | Type |
---|---|
hex | string |
SDK.utils.toFixed(value, digits) ⇒ value
formats a number using fixed-point notation
Kind: static method of utils
Param | Type | Default | Description |
---|---|---|---|
value | number | ||
digits | number | 5 | digits 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;
Param | Type | Default |
---|---|---|
value | value | |
inWei | boolean | false |
SDK.utils.BN(value) ⇒ BN
covert number to BN
Kind: static method of utils
Returns: BN - BN;
Param | Type |
---|---|
value | value |
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago