AIVIA JavaScript SDK
JavaScript Wrapper for interaction with AIVIA Protocol.
✅ Crypto Hedge Fund Template is supported
Ropsten TestNet.
Please note that THIS version is running onPlease 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"); // es6const AIVIA_SDK = require("aivia/sdk"); // es5 const ENTRY_POINT = "0x0000000000000000000000000000000000000000" // protocol entry point contract addressconst 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
- .getAuditDBAddress(addressOrSymbol) ⇒
AuditDBAddress
SDK.asset.getAuditDBAddress(addressOrSymbol) ⇒ returns AuditDB address
Kind: static method of Asset
Returns: AuditDBAddress
- AuditDB address
Param | Type |
---|---|
addressOrSymbol | string | address |
RPCAddress
SDK.asset.getRPCAddress(addressOrSymbol) ⇒ returns asset RPC address
Kind: static method of Asset
Returns: RPCAddress
- RPC address
Param | Type |
---|---|
addressOrSymbol | string | address |
rate
SDK.asset.getRate(addressOrSymbol) ⇒ returns asset rate by address or symbol
Kind: static method of Asset
Returns: rate
- current(last) rate
Param | Type |
---|---|
addressOrSymbol | string | address |
event
SDK.asset.updateRate(assetAddress, AUM, checksum, options, callback, estimate) ⇒ 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 |
NET
SDK.asset.NET(addressOrSymbol) ⇒ returns asset NET by address or symbol
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | string | address |
investors
SDK.asset.getInvestors(addressOrSymbol) ⇒ returns asset investors count by address
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | address |
object
SDK.asset.getConfig(assetAddress) ⇒ 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
- .getList() ⇒
Array.<assetsList>
SDK.asset.getList() ⇒ returns assets list array
Kind: static method of AssetsRegistry
Properties
Name | Type |
---|---|
assetsList.item | object |
item.symbol | string |
item.address | string |
address
SDK.asset.getAssetAddress(symbol) ⇒ returns asset address by symbol
Kind: static method of AssetsRegistry
Returns: address
- asset address
Param | Type |
---|---|
symbol | string |
symbol
SDK.asset.getAssetSymbol(assetAddress) ⇒ 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)
- .getConfigAddress(assetAddress) ⇒
address
SDK.project.getConfigAddress(assetAddress) ⇒ returns config address
Kind: static method of Project
Returns: address
- config address
Param | Type |
---|---|
assetAddress | address |
object
SDK.project.getConfig(configAddress) ⇒ returns config by config address
Kind: static method of Project
Returns: object
- config
Param | Type |
---|---|
configAddress | string | address |
transaction
SDK.project.update(configAddress, key, value, options, callback, estimate) ⇒ 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 |
transaction
SDK.project.updatePermissionRule(configAddress, rule, options, callback, estimate) ⇒ 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 |
transaction
SDK.project.updatePermission(configAddress, countryID, walletTypes, options, callback, estimate) ⇒ 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 |
boolean
SDK.project.getPermissionsRule(configAddress) ⇒ 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
components
SDK.project.deploy(type, params, options, callback, estimate) ⇒ 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
- .getBalance(wallet, [assetAddress]) ⇒
balance
SDK.asset.getBalance(wallet, [assetAddress]) ⇒ returns asset balance by assetAddress or ETH balance
Kind: static method of ERC20
Param | Type |
---|---|
wallet | address |
[assetAddress] | Address |
totalSupply
SDK.asset.totalSupply(assetAddress) ⇒ returns asset totalSupply
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
allowance
SDK.asset.allowance(assetAddress, owner, spender) ⇒ returns amount approved by owner to spender
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
owner | address |
spender | address |
event
SDK.asset.approve(assetAddress, spender, value, options, callback, estimate) ⇒ 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 |
event
SDK.asset.transfer(to, value, assetAddress, options, callback, estimate) ⇒ 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 |
event
SDK.asset.transferETH(to, value, options, callback, estimate) ⇒ 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 |
event
SDK.asset.mint(value, to, assetAddress, options, callback, estimate) ⇒ 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
- .getPlatformWallet() ⇒
address
SDK.platform.getPlatformWallet() ⇒ returns platform wallet address
Kind: static method of Platform
address
SDK.platform.getPlatformToken() ⇒ 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
- .checkBeforeBuy(value, assetAddress, currencyAddress, from) ⇒
true
| error
SDK.trade.checkBeforeBuy(value, assetAddress, currencyAddress, from) ⇒ 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 |
event
SDK.trade.buyAsset(value, assetAddress, currencyAddress, options, callback, estimate) ⇒ 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 |
true
| error
SDK.trade.checkBeforeSell(value, assetAddress, options) ⇒ 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 |
event
SDK.trade.sellAsset(value, assetAddress, options, callback, estimate) ⇒ 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 |
estimate
SDK.trade.estimate(value, assetAddress, [currencyAddress]) ⇒ 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
- .getList() ⇒
Array.<currenciesList>
SDK.platform.currency.getList() ⇒ returns platform currencies list
Kind: static method of Currency
Properties
Name | Type |
---|---|
currenciesList.item | object |
item.symbol | string |
item.address | string |
item.rate | number |
rate
SDK.platform.currency.getRate(addressOrSymbol) ⇒ returns currency rate by address or symbol
Kind: static method of Currency
Returns: rate
- - rate of currency
Param | Type |
---|---|
addressOrSymbol | string | address |
address
SDK.platform.currency.getAddress(symbol) ⇒ returns currency address by symbol
Kind: static method of Currency
Returns: address
- currency address
Param | Type |
---|---|
symbol | string |
symbol
SDK.platform.currency.getSymbol(currencyAddress) ⇒ 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>
- .addUser(userAddress, countryID, walletType, [expirationDate], options, callback, estimate) ⇒
event
SDK.auditor.addUser(userAddress, countryID, walletType, [expirationDate], options, callback, estimate) ⇒ 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 |
object
SDK.auditor.getUserDetails(userAddress) ⇒ 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 |
Array.<userList>
SDK.auditor.getUsersList() ⇒ 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
- .toHex(string) ⇒
hex
SDK.utils.toHex(string) ⇒ convert string to hex
Kind: static method of utils
Returns: hex
- the resulting HEX string;
Param | Type |
---|---|
string | string |
value
SDK.utils.toWei(value) ⇒ converts any value value into wei
Kind: static method of utils
Param | Type |
---|---|
value | number |
value
SDK.utils.fromWei(value) ⇒ converts any value from wei
Kind: static method of utils
Returns: value
- ;
Param | Type |
---|---|
value | number |
boolean
SDK.utils.isAddress(address) ⇒ check if a given string is a valid Ethereum address
Kind: static method of utils
Returns: boolean
- status;
Param | Type |
---|---|
address | address |
string
SDK.utils.toUtf8(hex) ⇒ converts any value from hex to string
Kind: static method of utils
Returns: string
- ;
Param | Type |
---|---|
hex | string |
value
SDK.utils.toFixed(value, [digits]) ⇒ 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; |
string
SDK.utils.numberToHex(value, [inWei]) ⇒ covert number to hex
Kind: static method of utils
Returns: string
- number;
Param | Type | Default |
---|---|---|
value | value |
|
[inWei] | boolean |
false |
BN
SDK.utils.BN(value) ⇒ covert number to BN
Kind: static method of utils
Returns: BN
- BN;
Param | Type |
---|---|
value | value |