Installation and use
Download
GitHub:https://github.com/MatrixAINetwork/aiman
Installation through npm
1 | npm install aiman |
Example
1 | //Initialization process |
aiman.version.network
Returns the network protocol version.
- Synchronous mode: aiman.version.network
- Asynchronous mode: aiman.version.getNetwork(callback(error, result){ … })
None
- String - Network protocol version.
1 | //Omit initialization |
aiman.setProvider
Set up Provider.
None
undefine
1 | aiman.setProvider(new aiman.providers.HttpProvider('http://localhost:8545')); |
aiman.sha3
Returns hashed results using Keccak-256 SHA3 algorithm.
- String - The inputted string that needs to be hashed using the Keccak-256 SHA3 algorithm.
- Object - Optional settings. If you want to parse a hexadecimal string in hex format, you need to set the encoding to hex. Because 0x is ignored by default in JS.
- String - The hashed results using Keccak-256 SHA3 algorithm.
1 | //Omit initialization |
aiman.toHex
Converts any value to HEX.
- String|Number|Object|Array|BigNumber - It needs to be converted to the value of HEX. If it is an object or array type, it will be converted to a string using JSON. If BigNumber is inputted, the corresponding Number’s HEX will be obtained.
- Hexadecimal string.
1 | //Initialize basic objects |
aiman.toAscii
Converts the HEX string to an ASCII string.
- String - Hexadecimal string.
- String - Given the ASCII code value corresponding to the hexadecimal string.
aiman.fromAscii
Converts any ASCII code string to a HEX string.
- String - ASCII code string.
- Number - The returned string byte size.It will be filled automatically if it is not long enough.
- String - The converted HEX string.
1 | var** str = aiman.fromAscii('matrix'); |
aiman.toDecimal
Converts a hexadecimal number to a decimal number.
- String - Hexadecimal string.
- Number - The hexadecimal value represented by the inputted string.
1 | var number = aiman.toDecimal('0x15'); |
aiman.fromDecimal
Converts a number, or a number in the form of a string, to a hexadecimal string.
- Number|String - Number
- String - The hexadecimal format of a given number.
1 | var value = aiman.fromDecimal('21'); |
aiman.toBigNumber
Converts a given number or hexadecimal string to BigNumber.
- Number|String - Numbers in digital or hexadecimal format
- BigNumber - Instance of BigNumber.
1 | var value = aiman.toBigNumber('200000000000000000000001'); |
aiman.net.listening
If the client is in a listening state, the call returns true.
- Synchronous mode: aiman.net.listening
- Asynchronous mode: aiman.net.getListener(callback(error, result){ … })
None
- Boolean - When the client is in a listening state, it returns true. Otherwise, it returns false.
1 | var listening = aiman.net.listening; |
aiman.net.peerCount
Returns the number of peers connected to the current client.
- Synchronous mode: aiman.net.peerCount
- Asynchronous mode: aiman.net.getPeerCount(callback(error, result){ … })
None
- Number - the number of connected peers.
1 | var peerCount = aiman.net.peerCount; |
aiman.man.defaultBlock
When using the following method, you will use the default block settings, and you can override the default configuration by inputting defaultBlock.
aiman.man.getBalance()
aiman.man.getCode()
aiman.man.getTransactionCount()
aiman.man.getStorageAt()
aiman.man.call()
The optional block parameter may be one of the following values:
- Number – Block number
- String – earliest, Genesis block.
- String – latest, the latest block just mined, the current block leader.
The default value is latest.
None
- Number|String - The block number of the status is checked by default.
1 | console.log("defaultBlock: " + aiman.man.defaultBlock); |
aiman.man.syncing
If it is synchronizing, it returns the synchronization object. Otherwise it returns false.
- Synchronous mode: aiman.man.syncing
- Asynchronous mode: aiman.man.getSyncing(callback(error, result){ … })
None
Object|Boolean - If it is synchronizing, it returns a synchronization object with the following properties.Otherwise it returns false.
- startingBlock: Number – The block number that started synchronization.
- currentBlock: Number – The block number that the node is currently synchronizing.
- highestBlock: Number – The estimated block number of the block to be synchronized to.
1 | var sync = aiman.man.syncing; |
aiman.man.mining
If the client is actively mining, the call returns true.
- Synchronous mode: aiman.man.coinbase
- Asynchronous mode: aiman.man.getCoinbase(callback(error, result){ … })
None
- Boolean - When the client is mining, it returns true, otherwise it returns false.
1 | var mining = aiman.man.mining; |
aiman.man.hashrate
Returns the number of hashes that can be calculated per second when mining.
- Synchronous mode: aiman.man.hashrate
- Asynchronous mode: aiman.man.getHashrate(callback(error, result){ … })
None
- Number - The number of hashes calculated per second.
1 | var hashrate = aiman.man.hashrate; |
aiman.man.gasPrice
Returns the current price of gas.
- Synchronous mode: aiman.man.gasPrice
- Asynchronous mode: aiman.man.getGasPrice(callback(error, result){ … })
None
- BigNumber - the current price of gas, unit: zhu.
1 | var gasPrice = aiman.man.gasPrice; |
aiman.man.accounts
Returns a list of address strings held by the client.
- Synchronous mode: aiman.man.accounts
- Asynchronous mode: aiman.man.getAccounts(callback(error, result){ … })
None
- Array - A list of address strings held by the client.
1 | var accounts = aiman.man.accounts; |
aiman.man.blockNumber
Returns the number of the latest block.
- Synchronous mode: aiman.man.blockNumber
- Asynchronous mode: aiman.man.getBlockNumber(callback(error, result){ … })
None
Number - the number of the current block.
1 | var number = aiman.man.blockNumber; |
aiman.man.getBalance
Returns the balance of the specified address account.
String - The address in which the balance needs to be checked.
Number|String -(Optional) If you do not set this value, use the block set by
aiman.man.defaultBlock
, otherwise use the specified block.Funciton - (Optional) Callback function that supports asynchronous execution [async].
OBJECT – The corresponding account currency balance object array is structured as
follows:
accountType:
QUANTITY
– Integer, currency number. 0, represents the main currency, MANbalance:
QUANTITY
– Integer, balance, Unit: zhu
Request:
1 | var number = aiman.man.blockNumber; |
Respons:
1 | [ |
aiman.man.getCode
Returns the code for the specified address.
- String - String, MAN address.
- String - String, currency name.
- Number|String -(Optional) If no parameters are inputted, the block defined by aiman.man.defaultBlock is used by default, otherwise the specified block is used.
- Function - Callback function that supports asynchronous execution [async].
- String - Compiled byte code for a given address contract.
1 | var code = aiman.man.getCode('MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb','MAN','latest'); |
aiman.man.getBlock
Returns the block corresponding to the block number or block hash value.
- Number|String – (Optional) If no parameters are inputted, the block defined by aiman.man.defaultBlock is used by default, otherwise the specified block is used.
- Boolean – (Optional) The default value is false. True returns all transactions contained in the block as objects. Otherwise only returns the hashes of the transactions.
- Function – Callback function that supports asynchronous execution [async].
- difficulty – BigNumber type. The difficulty of the current block, integer.
- elect – Array. Election information
- extraData – String. The extra data field of the current block.
- gasLimit – Number, the maximum gas allowed in the current block.
- gasUsed – The total gas used accumulatively in the current block.
- hash – String, hashes of blocks..
- leader –String. Leader of this block.
- miner – String. The miners in this block that are rewarded.
- mixHash – String. Mixed hash.
- nettopology – json object. Network topology
- nonce – String, 8 bytes. Hash generated by POW. When the block is pending, it returns null.
- Number – Block number. When the block is pending, it returns null.
- parentHash – String, the hash value of a 32-byte parent block.
- sha3Uncles – String, 32 bytes. Hash values of uncle blocks.
- sharding – Array, slice information
- signatures – Array, signature array.
- signHash – String, signature hash.
- size – Number. The byte size of the current block.
- stateRoot – Array, status information.
- timestamp – Number. Unix timestamp for block packing.
- totalDifficulty – BigNumber type. The total difficulty of starting block to the current block, integer.
- transactions – Array. The object of the transaction. Or a 32-byte transaction hash.
- uncles – Array. The array of uncle hash.
- Version – String. Version information
- VrfValue – String. Vrf information.
Request:
1 | var info = aiman.man.getBlock(3150); |
Respons:
1 | {"VrfValue":"0x038b5d8384b06f4f6006f1e27803ea7d26fc4e2b43dff3ad6839334b784500be9d04fdae385d7a70c70ad8de0d1c35a8e6e974b0c851ebaed2ca7d44896692c4d5936bc8b5d7c3be2ef0376808faef3aa038b8149a54a5ca6dd53d47dc313e7f82b7718080a40ad323b5425664307f153c60845c7c62f6c6c5109983095faaa186823316e88ea050d736b911e680b93a434c90983be6ec2cd826bfd4777de60cab8e", |
aiman.man.getBlockTransactionCount
Returns the number of transactions within the specified block.
- Number|String - block number.
- Function - Callback function that supports asynchronous execution [async].
- Nubmer - Number of transactions within a specified block.
1 | var number = aiman.man.getBlockTransactionCount(122); |
aiman.man.getTransaction
Returns a transaction with the specified hash value.
- aiman.man.getTransaction(transactionHash [, callback])
- String - transaction hash value.
- Function - Callback function that supports asynchronous execution [async].
Object - A transaction object.
- hash: String - 32 bytes – transaction hash.
- nonce: Number - Number of transactions that occurred prior to this transaction by the sender.
- blockHash: String - 32 bytes – Hash value of blocks containing transactions. Pending blocks return null
- blockNumber: Number - Block number of blocks containing transactions. Pending blocks return null
- transactionIndex: Number - Transaction Index. Pending blocks return null
- from: String - 20 bytes,Transaction sender address
- to: String - 20 bytes,Transaction receiver address
- value: BigNumber - he quantity of MAN sent, unit: zhu
- gasPrice: BigNumber - the price of gas paid by the sender, unit: zhu
- gas: Number - the amount of gas available to the sender
- input: String - data sent alongside the transaction
- IsEntrustTx
- 0: self-paid gas
- 1: gas paid by others
- CommitTime – submit time.
- matrixType – transaction types (normal transactions are set as 0)
- extra_to – extended transaction (should be filled for one to many transactions)
- TxEnterType – transaction pool types (normal transactions are set as 0)
- v – String,ECDSA recovery id
- r – String,ECDSA signature r
- s – String,ECDSA signature s
Request:
1 | var transaction = aiman.man.getTransaction('0x8838fd149ea46f4c182f2de9b465b731d6cb67794233602dddb5362474122841'); |
Respons:
1 | {"blockHash":"0x1d7d46eeee21cfb1028bc85d254e0cd432d3cc128624fc219340e0ee93db8f65", |
aiman.man.getTransactionFromBlock
Returns the transaction with the specified index number in the specified block.
- getTransactionFromBlock(hashStringOrNumber,indexNumber,Currency,[, callback])
- String – Block number or hash. Or earliest, latest string. Input aiman. man. defaultBlock to view optional values.
- Number – The serial number of the transaction.
- Currency – Currency name.
- Function – Callback function that supports asynchronous execution [async].
- Object - Transaction object. For details, see
aiman.man.getTransaction
.
1 | var transaction = aiman.man.getTransactionFromBlock('0x4534534534', 2); |
aiman.man.getTransactionReceipt
Returns the receipt for the specified transaction. The transactions are specified by hash.
- aiman.man.getTransactionReceipt(hashString[, callback])
Note: For pending transactions, receipts are not available.
- String - Transaction hash
- Function - Callback function that supports asynchronous execution [async].
Object - The transaction’s receipt object, if not found, it returns null
- blockHash: String - 32 bytes , hash of transaction blocks
- blockNumber: Number - transaction block number
- transactionHash: String - 32 bytes ,transaction hash
- transactionIndex: Number - transaction Index
- from: String- the address of transaction sender
- to: String - the address of transaction recipient.If it is a transaction created by a contract, returns null.
- cumulativeGasUsed: Number - Total gas consumption of blocks in the transaction process
- gasUsed: Number:The amount of gas consumed in transactions
- contractAddress:String - In a new contract creation transaction, this value is the newly created contract address. Otherwise, it returns null.
- logs: Array - An array of log objects generated by this transaction
Request:
1 | var receipt = aiman.man.getTransactionReceipt('0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b'); |
Respons:
1 | { |
aiman.man.getTransactionCount
Return to the number of transactions sent from a specified address.
- aiman.man.getTransactionCount(addressString [, defaultBlock] [, callback])
- String – Address
- Number|String – (Optional) If no parameters are inputted, the block defined by
aiman.man.defaultBlock
is used by default, otherwise the specified block is used. - Function – Callback function that supports asynchronous execution [async].
- Number - Number of transactions sent from a specified address.The starting number is 0x10000000000000.
1 | var number = aiman.man.getTransactionCount("MAN.38nGzwi5Xn5ApxHXquT8ALaMLpbyG"); |
aiman.man.sendTransaction
Launches a transaction.
- aiman.man.sendTransaction(transactionObject [, callback])
Object - The object of the transaction. The structure is as follows:
- from: String - Specified the sender’s address. If not specified, use aiman.man.defaultAccount.
- to: String - The target address of the transaction. If created by a contract, it is null
- value: Number|String|BigNumber - Number of currencies carried in a transaction, in zhu. If the transaction is created through a contract, it is the initial capital.
- gas: Number|String|BigNumber - The amount of gas used in transactions; unused gases will be returned.
- gasPrice: Number|String|BigNumber - Gas fees for transactions.
- data: String - (optional) a byte string containing relevant data. If created through a contract, it’s code for initialization
- nonce: Number - Integer, using this value you can use the same nonce to cover your own pending transactions
- Function - Callback function that supports asynchronous execution [async].
- Currency – Type of currency
- String - 32-byte transaction hash string. Denoted in hexadecimal.
When creating a contract, you can use aiman.man.getTransactionReceipt()
to get the contract address.
1 | // compiled solidity source code using https://chrisman.github.io/cpp-manereum/ |
aiman.man.sendRawTransaction
Initiates a transaction or contract to sign a transaction.
- aiman.man.sendRawTransaction(signedTransactionJSONObject [, callback])
- Object - The transaction object to be sent:
- to: String - The target address of the transaction. If created by a contract, it is null
- value: Number|String|BigNumber - Number of currencies carried in a transaction, in zhu. If the transaction is created through a contract, it is the initial capital.
- gas: Number|String|BigNumber - The amount of gas used in transactions; unused gases will be returned.
- gasPrice: Number|String|BigNumber - Gas fees for transactions
- data: String - (optional) a byte string containing relevant data. If created through a contract, it is the code used for initialization.
- nonce: Number -Integer, using this value you can use the same nonce to cover your own pending transactions.
- V: Signature results
- R: Signature results
- S: Signature results
- txEnterType Type of transaction pool (normal transaction set to 0)
- Currency: The type of currency
- TxType:transaction type (normal transaction set to 0)
- LockHeight:Reserved fields
- IsEntrustTx
- 0: self-paid gas
- 1: gas paid by others
- CommitTime:Submission time, available only for schduled and revocable transactions
- ExtraTo: Extended transactions (1 to more transactions should be filled in)
- Function - Callback function that supports asynchronous execution [async].
- String - 32 Bytes, transaction hash. If transaction is invalid, null is returned.
When creating a contract, you can use aiman.man.getTransactionReceipt()
to get the contract address.
1 | var rawtx= { |
aiman.man.call()
A new message call is executed immediately without creating a transaction on the blockchain.
- Object – The transaction object to be sent:
- from: STRING – The original address that send the transaction, optional
- to: STRING – Transaction target address
- Currency: STRING – Transaction currency name
- gas: QUANTITY – The amount of gas available for transaction, optional.
aiman.man.call
does not consume gas, but some implementations require this parameter - gasPrice: QUANTITY – Gas price, optional
- value: QUANTITY – The number of MAN tokens sent by the transaction, optional
- data: DATA – Method signature and hash of encoding parameters, optional
- QUANTITY|TAG – Integer block number, or the “latest”, “earliest” string
- DATA - Return Value of the executed contract.
1 | var obj = {"to": "MAN.468kLTuAEjm53ro2pPErnAAHqbccK","data": "0x58975919","currency": "MAN"}; |
aiman.man.sign
Signed by the specified account. The data needs to be sent while the account needs to be in the unlocked state.
- aiman.man.sign(address, dataToSign, [, callback])
- String - MAN Address
- String - Message to Sign
- Function -(Optional)Callback function that supports asynchronous execution [async].
String – Signed data.
The returned value corresponds to a string signed by ECDSA (Elliptic Curve Digital Signature Algorithm) 12.
r = signature[0:64]
s = signature[64:128]
v = signature[128:130]
Note that if you use ecrecover, the v value here is 00 or 01, so if you want to use them, you need to convert the v value here to an integer, plus 27. The final value you will use will be 27 or 2813.
1 | var result = aiman.man.sign("0x135a7de83802408321b74c322f8558db1679ac20", |
aiman.man.estimateGas
Executes and estimates the amount of gas required for a transaction. The transaction will not be written to the blockchain. Note that, for reasons such as the EVM mechanism and node performance, the estimated values may be much larger than during actual usage.
- aiman.man.estimateGas(callObject [, callback])
Refer to aiman.man.sendTransaction
, all properties are optional.
- Number - Gas consumed by simulated call/transaction.
1 | var r = aiman.man.estimateGas({currency:"MAN"}); |
aiman.man.getDepositByAddr
Returns the stake information of the specified account.
- aiman.man.getDepositByAddr(“MAN.4DnD4CZ1LNiHeb9SZNrn6XQfuETPC”,”latest”)
- String – String, MAN address.
- QUANTITY|TAG - Integer block number, “latest”、”earliest” string .
OBJECT – Stake account information, the information structure is as follows:
- AddressA0:STRING-The address of stake.
- AddressA1: STRING- The address of signature.
- OnlineTime: QUANTITY-Integer, online time, counted by block height.
- Role:QUANTITY-Election identity, 128: Verifiers; 16: Miners.
- PositionNonce: QUANTITY-Integer, position nonce value.
- Dpstmsg:OBJECT-stake position information list, stake warehouse information structure is as follows:
- DepositType:QUANTITY-Integer,//0-flexible,1-fixed1month,3-fixed3months,6-fixed6months.
- DepositAmount:QUANTITY-Integer, stake amount in zhu.
- Interest:QUANTITY-Integer,interest value in zhu.
- Slash:QUANTITY-Integer, punish value in zhu.
- BeginTime: QUANTITY-Integer, UTC time, the start time of stake; The start time of flexible stake is 0 .
- EndTime: QUANTITY-Integer, UTC time, represents the unstake time for fixed stakes, or the earliest withdrawal time for flexible stakes.
- Position: QUANTITY-Integer, the number of warehouse.
- WithDrawInfo:OBJECT-Refund object array, the information structure of refund object is as follows:
- WithDrawAmount:QUANTITY-Integer, refund amount in zhu
- WithDrawTime:QUANTITY-Integer, UTC time, refund time
Request:
1 | var result = aiman.man.getDepositByAddr("MAN.4DnD4CZ1LNiHeb9SZNrn6XQfuETPC","latest") |
Respons:
1 | { |
aiman.man.getDeposit()
Returns the stake information of the specified block. The block is specified by height.
- QUANTITY|TAG - Integer block number, or the “latest”, “earliest” string .
- OBJECT – The information of stake account is structured as follows:
- Address: STRING – The address of stake.
- SignAddress: STRING – The address of signature.
- Deposit: QUANTITY – Stake amount.
- Withdraw: QUANTITY – Election state, 0, in the election; non-0, withdrawal height.
- OnlineTime: QUANTITY – Integer, online time, counted by block height.
- Role: QUANTITY – Election identity, 128: Verifiers; 16: Miners.
Request:
1 | var var result = aiman.man. getDeposit("latest")); |
Respons:
1 | [ |
aiman.man.getMatrixCoin
Returns the multi-currency information.
- QUANTITY|TAG - Integer block number, or the “latest”, “earliest” string
- OBJECT – STRING array, the names of multi-currency.
Request:
1 | var result = aiman.man.getMatrixCoin('latest'); |
Respons:
1 | [ |
aiman.man.getMatrixCoinConfig
Returns the configuration information for multi-currency.
- STRING – The name of currency.
- QUANTITY|TAG - Integer block number, or the “latest”, “earliest” string
- OBJECT – Currency configuration information. The structure is as follows:
- CoinRange: STRING. The range of the coin.
- CoinType: STRING. The name of the coin.
- PackNum: QUANTITY. Integer, the maximum number of transactions per block.
- CoinUnit: QUANTITY. Integer, coin unit.
- CoinTotal: QUANTITY. Integer, coin total circulation.
- CoinAddress: DATA, 20 bytes. Coin transaction fee account address.
Request:
1 | var result = aiman.man.getMatrixCoinConfig("MBN","latest") |
Respons:
1 | [ |
aiman.man.getDestroyBalance
Returns the number of MANs consumed to create multiple currencies.
None
- QUANTITY - Integer, the number of MANs consumed to create multiple currencies in zhu.
Request:
1 | var result = aiman.man.getDestroyBalance() |
Respons:
1 | "0x152d02c7e14af6800000" // 100000000000000000000000 |
aiman.man.getSignAccounts
Returns a list of block signatures for the specified block. The block is specified by block hash/height.
block hash/height
- Object Array – The array of signature object. The signature structure is as follows:
- Sign: DATA, 65 bytes – signature
- Account:STRING, – signature account
- Validate:BOOL, – signature state。TRUE:signed;FALSE:unsigned
- Stock: QUANTITY, stock right. Invalid for now.
Request:
1 | var result = aiman.man.getSignAccounts(911); |
Respons:
1 | [ |
aiman.man.getValidatorGroupInfo
Returns the joint mining information of the specified block. Block is specified by block height.
- QUANTITY|TAG - Integer block number, or the “latest”, “earliest” string .
OBJECT – Joint Mining Information MAP. MAP: subcontract address as key value; STRING; slice with contract storage information as value, OBJECT.
The contract storage information structure is as follows:
- OwnerInfo.OBJECT, contract creation information is structured as follows:
- Owner: String – Owner account address
- SignAddress: String – Signature account address
- WithdrawAllTime: QUANTITY – All revocation time
- Reward.OBJECT, return allocation information is structured as follows:
- LevelRate: OBJECT – Participant Threshold and Returns Ratio Information, structured as follows:
- Rate: OBJECT – Distribution proportional coefficient { Decimal : denominator; Rate: numerator };
- Threshold: QUANTITY – Integer, minimum threshold for participation. Unit zhu.
- NodeRate: OBJECT – Management fee information is structured as follows:
- Decimal: QUANTITY – Integer, denominator of management fee ratio.
- Rate: QUANTITY – Integer, numerator of management fee ratio.
- OwnerRate: OBJECT – owner return ratio information, structured as follows:
- Decimal: QUANTITY – Integer, denominator of owner’s return ratio.
- Rate: QUANTITY – Integer, numerator of owner’s return ratio.
- ValidatorMap: OBJECT, an array of participant information, including Owner; participant information structure is as follows:
- Address: STRING – Participant account address;
- Reward: QUANTITY – Integer, Incentive distribution accumulated value.
- AllAmount: QUANTITY – Integer, Total stake amount.
- Current: OBJECT – flexible stake information, structured as follows:
- Amount: QUANTITY – Integer, the amount of flexible stake.
- PreAmount: QUANTITY – Integer, the amount of flexible stake in the previous round.
- Interest: QUANTITY – Integer, flexible interest.
- WithdrawList: Withdraw stake information list a) WithDrawAmount Withdraw Amount;b) .
- WithDrawTime :Withdraw time
- Positions: OBJECT – fixed stake warehouse information list; fixed stake information is structured as follows:
- DType: QUANTITY – Integer, fixed stake type
- Position: QUANTITY – Integer, fixed stake warehouse
- Amount: QUANTITY – Integer, fixed stake amount
- EndTime: QUANTITY – Integer, fixed stake end time
- LevelRate: OBJECT – Participant Threshold and Returns Ratio Information, structured as follows:
Request:
1 | var result = aiman.man.getValidatorGroupInfo(“latest”); |
Respons:
1 | { |
aiman.man.getStorageAt
Returns the value of the specified address storage location.
- STRING –String, MAN address
- QUANTITY – Location number in storage
- STRING –String, currency name
- QUANTITY|TAG – Integer block number, or the “latest”, “earliest” string
- DATA - The value of the specified storage location.
Request:
1 | var result = aiman.man.getStorageAt("MAN.468kLTuAEjm53ro2pPErnAAHqbccK",12,"MAN","latest") |
Respons:
1 | {"0x000000000000000000000000000000000000000000000000000000000000162e"} |
aiman.man.getTopologyStatusByNumber
Returns the top-level node topology information of the specified block. Block is specified by height.
- QUANTITY|TAG - Integer block number, or the “latest”, “earliest” string
Object – Matched Topological Information Objects. The structure is as follows:
- leader_reelect: BOOL – Verifier Reelection Status. False: No verifier re-election occurred; True: Verifier re-election occurred;
- validators: An array of verifier information. The verifier information structure is as follows:
- account: STRING – Account;
- online: BOOL – Online status. True: Online; False: Offline
- position: QUANTITY – Location number
- backup_validators: Backup the verifier information array. For backup verifier information structure, see verifier information structure.
- miners: Miners information array. For miner information structure, see verifier information structure.
- elect_validators: Verifier masternode consensus online and offline information. For information structure, see verifier information structure.
- electbackupvalidators: Verifier backup node consensus online and offline information. For information structure, see verifier information structure.
Request:
1 | var result = aiman.man.getTopologyStatus(120); |
Respons:
1 | { |
aiman.man.getBlackList
Returns transaction blacklist accounts, which cannot transfer transactions.
None
OBJECT: String array – Blacklisted transaction account address.
Request:
1 | var result = aiman.man.getBlackList(); |
Respons:
1 | {"MAN.4Pn182LSJ3JNr9by4T5kDKsf127Jb"," MAN.Tfr4DZYNeWqqTth87phrg2KZcqya"} |
Note: Non-consensus data, node data, are unauthenticated on the chain.`
aiman.man.getSelfLevel
Returns the identity of the current node in the network.
None
QUANTITY – Identity mark. 0: Error; 1-4 bucket; 5 top-level nodes; 6 basic nodes.
1 | console.log(aiman.man.getSelfLevel()); // 6 |
aiman.man.getUpTime
Returns the uptime of the specified account from the latest mortgage to the specified block. The block is specified by the block height.
- STRING – Account address
- QUANTITY|TAG – Integer block number, or the “latest”, “earliest” string
- QUANTITY – Integer online time, counted by block height.
1 | console.log(aiman.man.getUpTime("MAN.4Kq1ciivykmrCFzz5YjLgamcNdU76")) //0x85edb |
aiman.man.newBlockFilter
Creates a filter in the node to notify when a new block is generated. To check whether the state changes, call aiman.man.getFilterChanges
。
None
QUANTITY - Filter Number
Request:
1 | var result = aiman.man.newBlockFilter(); |
Respons:
1 | " 0x15842a94627e19e5571559236b5b1700 " |
aiman.man.uninstallFilter
Uninstalls a filter with a specified number. When you do not need to listen, you always need to execute the call. In addition, if the filter does not receive the aiman.man.getFilterChanges
call within a certain period of time, it will automatically timeout.
- QUANTITY - Filter Number
- Boolean - Return true if uninstalled successfully, otherwise return false
1 | var result aiman.man.uninstallFilter("0xb"); // true |
aiman.man.getEntrustList
Returns entrust list for specified authorized account.
- STRING- Authorized account address.
OBJECT – Entrusted account information list. The information structure of the entrusted account is as follows:
- EntrustAddres: STRING – Entrusted account address
- IsEntrustGas: BOOLEAN – Whether to entrust others to pay for gas. True means that gas is paid by others entrusted.
- IsEntrustSign: BOOLEAN – Whether to entrust signature or not. True means that it is an entrusted signature.
- EnstrustSetType: DATA, 1byte- 0: entrusted by height, 1: entrusted by time, 2: entrusted by number of times
- StartHeight: QUANTITY – Integer block number, start height of entrust
- EndHeight: QUANTITY – Integer block number, end height of entrust
- StartTime: QUANTITY – UTC time, start time of entrust
- EndTime: QUANTITY – UTC time, end time of entrust
- EntrustCount: QUANTITY – Number of entrusts
Request:
1 | var result = aiman.man.getEntrustList("MAN.21LDRQtTVBdv3EcktxrVQebpQmLEA”); |
Respons:
1 | [ |