JavaScript Wrapper for interaction with AIVIA Protocol.
✅ Crypto Hedge Fund Template is supported
Please note that THIS version is running on Ropsten TestNet.
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"
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
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 );
- 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) ⇒
returns AuditDB address
Kind: static method of Asset
Returns: AuditDBAddress
- AuditDB address
Param | Type |
---|---|
addressOrSymbol | string | address |
returns asset RPC address
Kind: static method of Asset
Returns: RPCAddress
- RPC address
Param | Type |
---|---|
addressOrSymbol | string | address |
returns asset rate by address or symbol
Kind: static method of Asset
Returns: rate
- current(last) rate
Param | Type |
---|---|
addressOrSymbol | string | address |
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 |
returns asset NET by address or symbol
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | string | address |
returns asset investors count by address
Kind: static method of Asset
Param | Type |
---|---|
addressOrSymbol | address |
returns config by config address
Kind: static method of Asset
Returns: object
- config
Param | Type |
---|---|
assetAddress | string | address |
- AssetsRegistry
- .getList() ⇒
Array.<assetsList>
- .getAssetAddress(symbol) ⇒
address
- .getAssetSymbol(assetAddress) ⇒
symbol
- .getList() ⇒
returns assets list array
Kind: static method of AssetsRegistry
Properties
Name | Type |
---|---|
assetsList.item | object |
item.symbol | string |
item.address | string |
returns asset address by symbol
Kind: static method of AssetsRegistry
Returns: address
- asset address
Param | Type |
---|---|
symbol | string |
returns asset symbol by address
Kind: static method of AssetsRegistry
Returns: symbol
- asset symbol
Param | Type |
---|---|
assetAddress | address |
- 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) ⇒
returns config address
Kind: static method of Project
Returns: address
- config address
Param | Type |
---|---|
assetAddress | address |
returns config by config address
Kind: static method of Project
Returns: object
- config
Param | Type |
---|---|
configAddress | string | address |
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 |
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 |
returns permissions rule(tru or false)
Kind: static method of Project
Returns: boolean
- rule
Param | Type |
---|---|
configAddress | string | address |
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 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
- .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]) ⇒
returns asset balance by assetAddress or ETH balance
Kind: static method of ERC20
Param | Type |
---|---|
wallet | address |
[assetAddress] | Address |
returns asset totalSupply
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
returns amount approved by owner to spender
Kind: static method of ERC20
Param | Type |
---|---|
assetAddress | address |
owner | address |
spender | address |
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 |
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 |
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 |
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
- .getPlatformWallet() ⇒
address
- .getPlatformToken() ⇒
address
- .getPlatformWallet() ⇒
returns platform wallet address
Kind: static method of Platform
returns platform token address
Kind: static method of Platform
- 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) ⇒
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 |
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 |
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 |
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 |
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
- .getList() ⇒
Array.<currenciesList>
- .getRate(addressOrSymbol) ⇒
rate
- .getAddress(symbol) ⇒
address
- .getSymbol(currencyAddress) ⇒
symbol
- .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 |
returns currency rate by address or symbol
Kind: static method of Currency
Returns: rate
- - rate of currency
Param | Type |
---|---|
addressOrSymbol | string | address |
returns currency address by symbol
Kind: static method of Currency
Returns: address
- currency address
Param | Type |
---|---|
symbol | string |
returns currency symbol by address
Kind: static method of Currency
Returns: symbol
- currency symbol
Param | Type |
---|---|
currencyAddress | address |
- TPLRegistry
- .addUser(userAddress, countryID, walletType, [expirationDate], options, callback, estimate) ⇒
event
- .getUserDetails(userAddress) ⇒
object
- .getUsersList() ⇒
Array.<userList>
- .addUser(userAddress, countryID, walletType, [expirationDate], options, callback, estimate) ⇒
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 |
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 |
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
- .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) ⇒
convert string to hex
Kind: static method of utils
Returns: hex
- the resulting HEX string;
Param | Type |
---|---|
string | string |
converts any value value into wei
Kind: static method of utils
Param | Type |
---|---|
value | number |
converts any value from wei
Kind: static method of utils
Returns: value
- ;
Param | Type |
---|---|
value | number |
check if a given string is a valid Ethereum address
Kind: static method of utils
Returns: boolean
- status;
Param | Type |
---|---|
address | address |
converts any value from hex to string
Kind: static method of utils
Returns: string
- ;
Param | Type |
---|---|
hex | string |
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; |
covert number to hex
Kind: static method of utils
Returns: string
- number;
Param | Type | Default |
---|---|---|
value | value |
|
[inWei] | boolean |
false |
covert number to BN
Kind: static method of utils
Returns: BN
- BN;
Param | Type |
---|---|
value | value |