JAVA API

netVersion()

Returns the network protocol version.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.NetVersion> netVersion();
Parameter

None

Return Value
  • NetVersion
    • String - Network protocol version.’1’- MAN Mainnet,’3’- MAN Testnet
Example
1
2
3
//net_Version
NetVersion netVersion = aiManj.netVersion().send();
System.out.println("netVersion:"+netVersion.getNetVersion());

netListening ()

If the client is in a listening state, the call returns true.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.NetListening> netListening();
Parameter

None

Return Value
  • NetListening
    • Boolean - When the client is in a listening state, it returns true. Otherwise, it returns false.
Example
1
2
3
//net_listening
NetListening netListening = aiManj.netListening().send();
System.out.println("netListening:"+netListening.isListening());

netPeerCount ()

Returns the number of peers connected to the current client.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.NetPeerCount> netPeerCount();
Parameter

None

Return Value
  • NetPeerCount
    • Number - the number of connected peers.
Example
1
2
3
// net_peerCount
NetPeerCount netPeerCount = aiManj.netPeerCount().send();
System.out.println("netPeerCount:"+netPeerCount.getQuantity());

manProtocolVersion ()

Returns the version of the current protocol.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManProtocolVersion> manProtocolVersion();
Parameter

None

Return Value
  • ManProtocolVersion
    • String - the version of the current protocol.
Example
1
2
3
// man_protocolVersion
ManProtocolVersion manProtocolVersion = aiManj.manProtocolVersion().send();
System.out.println("manProtocolVersion:"+manProtocolVersion.getResult());

manMining ()

If the client is actively mining, the call returns true.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManMining> manMining();
Parameter

None

Return Value
  • ManMining
    • Boolean - When the client is mining, it returns true, otherwise it returns false.
Example
1
2
// man_mining
ManMining manMining = aiManj.manMining().send(); System.out.println("manMining:"+manMining.isMining());

manHashrate ()

Returns the number of hashes that can be calculated per second when mining.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManHashrate> manHashrate();
Parameter

None

Return Value
  • ManHashrate
    • Number - The number of hashes calculated per second.
Example
1
2
3
// man_hashrate
ManHashrate manHashrate = aiManj.manHashrate().send();
System.out.println("manMining:"+manHashrate.getHashrate());

manGetDepositByAddr ()

Returns the stake information of the specified account.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetDepositAddr> manGetDepositByAddr(java.lang.String arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • String – MAN address.
  • DefaultBlockParameter
Return Value

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
Example
1
2
3
// man_getDepositByAddr
ManGetDepositAddr manGetDepositAddr = aiManj.manGetDepositByAddr("MAN.qTgjcxe3U6R3P6xD1x7YD9A8v1dD", DefaultBlockParameterName.LATEST).send();
System.out.println("manGetDepositAddr:"+manGetDepositAddr.getResult());

manGetDeposit ()

Returns the stake information of the specified block. The block is specified by height.

Parameter
  • DefaultBlockParameter
Return Value

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.
Example
1
2
3
// man_getDeposit
ManGetDeposit manGetDeposit = aiManj.manGetDeposit(DefaultBlockParameterName.LATEST).send();
System.out.println("manGetDeposti:"+manGetDeposit.getDeposit());

manGetMatrixCoin ()

Returns the multi-currency information.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetMatrixCoin> manGetMatrixCoin(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value
  • ManGetMatrixCoin – array, the names of multi-currency.
Example
1
2
3
// man_getMatrixCoin
ManGetMatrixCoin manGetMatrixCoin = aiManj.manGetMatrixCoin(DefaultBlockParameterName.LATEST).send();
System.out.println("manGetMatrixCoin:"+manGetMatrixCoin.getMatrixCoin());

manGetMatrixCoinConfig ()

Returns the configuration information for multi-currency.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetMatrixCoinConfig> manGetMatrixCoinConfig(java.lang.String arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • STRING – The name of currency.
  • DefaultBlockParameter
Return Value
  • 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.
Example
1
2
ManGetMatrixCoinConfig manGetMatrixCoinConfig = aiManj.manGetMatrixCoinConfig("XMA", DefaultBlockParameterName.LATEST).send();
System.out.println("manGetMatrixCoinConfig" + manGetMatrixCoinConfig.getMatrixCoinConfig());

manGetDestroyBalance ()

Returns the number of MANs consumed to create multiple currencies.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.GetDestroyBalance> manGetDestroyBalance(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value
  • GetDestroyBalance
    • String,the number of MANs consumed to create multiple currencies in zhu.
Example
1
2
3
DefaultBlockParameter defaultBlockParameter = new DefaultBlockParameterNumber(11);
GetDestroyBalance GetDestroyBalance = aiManj.manGetDestroyBalance(defaultBlockParameter).send();
System.out.println("GetDestroyBalance" + GetDestroyBalance.getDestroyBalance());

manGetSignAccountsByHash ()

Returns a list of block signatures for the specified block. The block is specified by block hash.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetSignAccountsByHash> manGetSignAccountsByHash(java.lang.String arg0);
Parameter

String - block hash

Return Value
  • 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.
Example
1
2
ManGetSignAccountsByHash manGetSignAccountsByHash = aiManj.manGetSignAccountsByHash("0x6f56342215d11d2181f88f897dfd93da80dbaa686e6b2288178d8ec30e1b88a9").send();
System.out.println("manGetSignAccountsByHash" + manGetSignAccountsByHash.getSignAccounts());

manGetSignAccountsByNumber ()

Returns a list of block signatures for the specified block. The block is specified by block height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetSignAccountsByHash> manGetSignAccountsByNumber(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value
  • 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.
Example
1
2
ManGetSignAccountsByHash manGetSignAccountsByHash2 = aiManj.manGetSignAccountsByNumber(defaultBlockParameter).send();
System.out.println("manGetSignAccountsByHash" + manGetSignAccountsByHash2.getSignAccounts());

manCall ()

A new message call is executed immediately without creating a transaction on the blockchain.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManCall> manCall(org.aimanj.protocol.core.methods.request.Transaction arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • Transaction – 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
  • DefaultBlockParameter

Return Value
  • ManCall
    • String - Return Value of the executed contract.
Example
1
2
3
4
5
6
7
List list = new ArrayList();
ManGetTransactionCount count = aiManj
.manGetTransactionCount("MAN.5xYzBHrJfXeJi9yQ8Qq8hvm19bU4", DefaultBlockParameterName.LATEST).send();
Transaction transaction = new Transaction("MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj",count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), "MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj", BigInteger.ZERO, "","MAN",BigInteger.ZERO,BigInteger.ZERO, BigInteger.ZERO, list);
ManCall manCall = aiManj.manCall(transaction, DefaultBlockParameterName.LATEST).send();
System.out.println("manCall" + manCall.getResult());

manGetValidatorGroupInfo ()

Returns the joint mining information of the specified block. Block is specified by block height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetMap> manGetValidatorGroupInfo(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value

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
Example
1
2
ManGetMap mangetvalidator = aiManj.manGetValidatorGroupInfo(DefaultBlockParameterName.LATEST).send();
System.out.println("mangetvalidator" + mangetvalidator.getResult());

manGetStorageAt ()

Returns the value of the specified address storage location.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetStorageAt> manGetStorageAt(java.lang.String arg0, java.math.BigInteger arg1, java.lang.String arg2, org.aimanj.protocol.core.DefaultBlockParameter arg3);
Parameter
  • String- MAN address
  • BigInteger - Location number in storage
  • String – currency name
  • DefaultBlockParameter
Return Value
  • ManGetStorageAt - The value of the specified storage location.
Example
1
2
ManGetStorageAt manGetStorageAt = aiManj.manGetStorageAt("MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj", new BigInteger("0"),"MAN",DefaultBlockParameterName.LATEST ).send();
System.out.println("manGetStorageAt:" + manGetStorageAt.getResult());

manGetTopologyStatusByNumber ()

Returns the top-level node topology information of the specified block. Block is specified by height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetMap> manGetTopologyStatusByNumber(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value

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.
Example
1
2
3
// man_getTopologyStatusByNumber
ManGetMap manGetTopology = aiManj.manGetTopologyStatusByNumber(new DefaultBlockParameterNumber(12)).send();
System.out.println("manGetTopology:" + manGetTopology.getResult());

manGetBlackList ()

Returns transaction blacklist accounts, which cannot transfer transactions.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetMap> manGetBlackList();
Parameter

None

Return Value

String array – Blacklisted transaction account address.

Example
1
2
3
// man_getBlackList
ManGetMap manGetBlackList = aiManj.manGetBlackList().send();
System.out.println("manGetBlackList:" + manGetBlackList.getResult());

manBlockNumber ()

Returns the number of the latest block.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManBlockNumber> manBlockNumber();
Parameter

None

Return Value

BigInteger- the number of the current block.

Example
1
2
3
4
// man_blockNumber
ManBlockNumber manBlockNumber = aiManj.manBlockNumber().send();
BigInteger blockNumber = manBlockNumber.getBlockNumber();
System.out.println("链的块高:" + blockNumber);

manEstimateGas ()

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.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManEstimateGas> manEstimateGas(org.aimanj.protocol.core.methods.request.Transaction arg0);
Parameter

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
Return Value
  • bigInteger - Gas consumed by simulated call/transaction.
Example
1
2
3
4
5
6
7
List list = new ArrayList();
ManGetTransactionCount count = aiManj
.manGetTransactionCount("MAN.5xYzBHrJfXeJi9yQ8Qq8hvm19bU4", DefaultBlockParameterName.LATEST).send();
Transaction transaction = new Transaction("MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj",count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), "MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj", BigInteger.ZERO, "","MAN",BigInteger.ZERO,BigInteger.ZERO, BigInteger.ZERO, list);
ManEstimateGas manEstimateGas = aiManj.manEstimateGas(transaction).send();
System.out.println("manEstimateGas:" + manEstimateGas.getResult());

manGetBalance ()

Returns the balance of the specified address account.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetBalance> manGetBalance(java.lang.String arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • String - The address in which the balance needs to be checked.
  • DefaultBlockParameter
Return Value

OBJECT – The corresponding account currency balance object array is structured as
follows:

  • accountType:QUANTITY – Integer, currency number. 0, represents the main currency, MAN
  • balance:QUANTITY – Integer, balance, Unit: zhu
Example
1
2
3
4
5
6
ManGetBalance manGetBalance = aiManj
.manGetBalance("MAN.JLuY5HhAiEW7KB8bh1EbN41gPCqT", DefaultBlockParameterName.LATEST).send();
List<Map<String, BigInteger>> balance = manGetBalance.getBalance();
for(int i = 0, length = balance.size(); i < length; i++) {
System.out.println("地址帐户" + (i + 1) + "余额:" + Convert.fromWei(new BigDecimal(balance.get(i).get("balance")), Convert.Unit.ETHER));
}

manGetSelfLevel ()

Returns the identity of the current node in the network.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetString> manGetSelfLevel();
Parameter

None

Return Value

Identity mark. 0: Error; 1-4 bucket; 5 top-level nodes; 6 basic nodes.

Example
1
2
3
// man_getSelfLevel
ManGetString getSelfLevel = aiManj.manGetSelfLevel().send();
System.out.println("getSelfLevel:" + getSelfLevel.getResult());

manGetCode ()

Returns the code for the specified address.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetCode> manGetCode(java.lang.String arg0, java.lang.String arg1, org.aimanj.protocol.core.DefaultBlockParameter arg2);
Parameter
  • String - MAN address.
  • String - currency name.
  • DefaultBlockParameter
Return Value
  • Compiled byte code for a given address contract.
Example
1
2
3
// man_getCode
ManGetCode manGetCode = aiManj.manGetCode("MAN.4SYA8BxUZaevRXczJvdoSMT2p89Np","MAN",DefaultBlockParameterName.LATEST).send();
System.out.println("man Code:" + manGetCode.getCode());

manGasPrice ()

Returns the current price of gas.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGasPrice> manGasPrice();
Parameter

None

Return Value
  • Integer- the current price of gas, unit: zhu.
Example
1
2
3
ManGasPrice manGasPrice = aiManj.manGasPrice().send();
BigInteger gasPrice = manGasPrice.getGasPrice();
System.out.println("gasPrice:" + gasPrice);

manGetUpTime ()

Returns the uptime of the specified account from the latest mortgage to the specified block. The block is specified by the block height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetString> manGetUpTime(java.lang.String arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • STRING – Account address
  • DefaultBlockParameter
Return Value
  • STRING – online time, counted by block height.
Example
1
2
3
// man_getUpTime
ManGetString manGetUpTime = aiManj.manGetUpTime("MAN.4SYA8BxUZaevRXczJvdoSMT2p89Np", DefaultBlockParameterName.LATEST).send();
System.out.println("manGetUpTime:" + manGetUpTime.getResult());

manGetTransactionByBlockNumberAndIndex ()

Returns the transaction with the specified index number in the specified block.The block is specified by the block height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManTransaction> manGetTransactionByBlockNumberAndIndex(org.aimanj.protocol.core.DefaultBlockParameter arg0, java.math.BigInteger arg1, java.lang.String arg2);
Parameter
  • DefaultBlockParameter
  • BigInteger - The serial number of the transaction.
  • String - Currency name.
Return Value

See manGetTransactionByHash()

Example
1
2
3
//man_getTransactionByBlockNumberAndIndex
ManTransaction mantrans2 = aiManj.manGetTransactionByBlockNumberAndIndex(DefaultBlockParameterName.LATEST, new BigInteger("0"),"MAN").send();
System.out.println("mantrans2:" + mantrans2.getResult());

manGetTransactionByBlockHashAndIndex ()

Returns the transaction with the specified index number in the specified block.The block is specified by the hash.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManTransaction> manGetTransactionByBlockHashAndIndex(java.lang.String arg0, java.math.BigInteger arg1, java.lang.String arg2);
Parameter
  • String - Transaction hash.
  • BigInteger - The serial number of the transaction.
  • String – Currency name.
Return Value

参考manGetTransactionByHash()

Example
1
2
3
// manGetTransactionByBlockHashAndIndex
ManTransaction mantrans = aiManj.manGetTransactionByBlockHashAndIndex("0x0cdb12533e0856b10136123bc7541d3b1030f98ca776b27e61828827477aa3b1", new BigInteger("0"),"MAN").send();
System.out.println("mantrans2:" + mantrans.getResult());

manGetTransactionByHash ()

Returns a transaction with the specified hash value.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManTransaction> manGetTransactionByHash(java.lang.String arg0);
Parameter

String - transaction hash value.

Return Value

Object – The object of the transaction. If no matching transaction is found, null is returned. The structure is as follows:

  • hash: DATA, 32 bytes – transaction hash
  • nonce: QUANTITY – Number of transactions that occurred prior to this transaction by the sender
  • blockHash: DATA, 32 bytes – Hash value of blocks containing transactions. Pending blocks return null
  • blockNumber: QUANTITY – Block number of blocks containing transactions. Pending blocks return null
  • transactionIndex: QUANTITY – Transaction Index. Pending blocks return null
  • from: String, – Transaction sender address
  • to: String, – Transaction receiver address
  • value: QUANTITY – the quantity of MAN sent, unit: zhu
  • gasPrice: QUANTITY – the price of gas paid by the sender, unit: zhu
  • gas: QUANTITY – the amount of gas available to the sender
  • input: DATA – data sent alongside the transaction
  • v: QUANTITY – ECDSA recovery id
  • r: DATA, 32 bytes – ECDSA signature r
  • s: DATA, 32 bytes– ECDSA signature s
  • TxEnterType: transaction pool types (normal transactions are set as 0)
  • matrixType: transaction types (normal transactions are set as 0)
  • IsEntrustTx:
    • 0: self-paid gas
    • 1: gas paid by others
  • CommitTime: submit time, available to scheduled transactions and revocable transactions only
  • Currency: type of currency
  • ExtraTo: extended transaction (should be filled for one to many transactions)
Example
1
2
3
// man_getTransactionByHash
ManTransaction mantrans3 = aiManj.manGetTransactionByHash("0xe39b151b90695051f966707c67dc1515bdb75d28c087b23199a01f688d8174e2").send();
System.out.println("mantrans3:" + mantrans3.getResult());

manGetBlockTransactionCountByHash ()

Return to the number of transactions sent from a specified address.The block is specified by the hash.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetBlockTransactionCountByHash> manGetBlockTransactionCountByHash(java.lang.String arg0);
Parameter
  • String - Block hash。
Return Value
  • ManGetBlockTransactionCountByHash
    • BigInteger - Number of transactions within a specified block.
Example
1
2
3
// man_getBlockTransactionCountByHash
ManGetBlockTransactionCountByHash manGetBlockTransactionCountByHash = aiManj.manGetBlockTransactionCountByHash("0xeb2e36f3ddbf07be7b71f22276011f8d6acf1eb6f0892925906e71b505a711ae").send();
System.out.println("manGetBlockTransactionCountByHash:" + manGetBlockTransactionCountByHash.getTransactionCount());

manGetTransactionCount ()

Return to the number of transactions sent from a specified address.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetTransactionCount> manGetTransactionCount(java.lang.String arg0, org.aimanj.protocol.core.DefaultBlockParameter arg1);
Parameter
  • String - MAN address
  • DefaultBlockParameter
Return Value
  • BigInteger - Number of transactions sent from a specified address.The starting number is 0x10000000000000.
Example
1
2
3
4
5
ManGetTransactionCount manGetTransactionCount = aiManj
.manGetTransactionCount("MAN.JLuY5HhAiEW7KB8bh1EbN41gPCqT", DefaultBlockParameterName.LATEST).send();
BigInteger transactionCount = manGetTransactionCount.getTransactionCount();

System.out.println("地址的nonce:" + transactionCount);

manGetTransactionReceipt ()

Returns the receipt for the specified transaction. The transactions are specified by hash.

Please note that receipts for pending transactions are invalid.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetTransactionReceipt> manGetTransactionReceipt(java.lang.String arg0);
Parameter
  • String - Transaction hash
Return Value

Object – Transaction recipients. If the receipt does not exist, null is returned. The structure of transaction options is as follows:

  • transactionHash: DATA, 32 bytes – transaction hash
  • transactionIndex: QUANTITY – transaction Index
  • Currency:STRING-currency name
  • blockHash: DATA, 32 bytes – hash of transaction blocks
  • blockNumber: QUANTITY – transaction block number
  • from: String, the address of transaction sender
  • to: String, the address of transaction recipient
  • cumulativeGasUsed: QUANTITY – Total gas consumption of blocks in the transaction process
  • gasUsed: QUANTITY – 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
  • logsBloom: DATA, 256 bytes– bloom filter, lightweight client for fast extraction of related logs
  • status: QUANTITY, 1 (Success) or 0 (Failure)
Example
1
2
ManGetTransactionReceipt transactionReceipt = aiManj.manGetTransactionReceipt("0x7642a93a137df23bcb31c82365c2c4dcd3067f6794168fbaab6db0d7c0b964cd").send();
System.out.println("transactionReceipt:"+transactionReceipt.getTransactionReceipt());

manSendTransaction ()

Launches a transaction.

Function Prototype
1
  public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManSendTransaction> manSendTransaction(org.aimanj.protocol.core.methods.request.Transaction arg0);
Parameter

Object – The object of the transaction. The structure is as follows:

  • from: String – Specified the sender’s address. If not specified, use man.defaultAccount.
  • to: String – The target address of the transaction. If created by a contract, it is null
  • Note: If the transaction is issuing 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
  • Currency: Type of currency
  • ExtraTo: Extended transactions (1 to more transactions should be filled in)
Return Value
  • String - 32-byte transaction hash string. Denoted in hexadecimal.

When creating a contract, you can use manGetTransactionReceipt() to get the contract address.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// man_sendTransaction
List list = new ArrayList();
ManGetTransactionCount count = aiManj
.manGetTransactionCount("MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo", DefaultBlockParameterName.LATEST).send();

//normal transaction
Transaction transaction = new Transaction("MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo",count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), "MAN.aR54tfdEWDfsfHhdsy6BkRVGRYLj", BigInteger.ZERO,"0x", "MAN",BigInteger.ZERO, BigInteger.ZERO,BigInteger.ZERO, list);

//contract transaction
Transaction contractTransaction = Transaction.createContractTransaction("MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo", count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), BigInteger.ZERO, "0x", "MAN", BigInteger.ZERO, BigInteger.ZERO, BigInteger.ZERO, list);

// send contract transaction
ManSendTransaction manSendConstractTransaction = aiManj.manSendTransaction(contractTransaction).send();
System.out.println("manCall" + manSendConstractTransaction.getTransactionHash());

// send normal transaction
ManSendTransaction manSendTransaction = aiManj.manSendTransaction(transaction).send();
System.out.println("manCall" + manSendTransaction.getTransactionHash());

manSendRawTransaction ()

Initiates a transaction or contract to sign a transaction.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManSendTransaction> manSendRawTransaction(java.lang.String arg0);
Parameter

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)
  • TxEnterType:transaction pool types(normaltransactions are set as 0)
Return Value
  • String - transaction hash.

When creating a contract, you can use manGetTransactionReceipt()to get the contract address.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
List list = new ArrayList();
ManGetTransactionCount count = aiManj
.manGetTransactionCount("MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo", DefaultBlockParameterName.LATEST).send();
// normal transaction
RawTransaction rawTransaction = RawTransaction.createTransaction(count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), "MAN.2nRsUetjWAaYUizRkgBxGETimfUTz",
"0x12131a","MAN", BigInteger.ZERO, BigInteger.ZERO, BigInteger.ZERO, list);

// contract transaction
RawTransaction rawContractTransaction = RawTransaction.createContractTransaction(count.getTransactionCount(),
new BigInteger("18000000000"), new BigInteger("210000"), BigInteger.ZERO, "0x12131a","MAN",BigInteger.ZERO, BigInteger.ZERO, BigInteger.ZERO, list);


byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, chainid,
Credentials.create("3ec3678077a79400081e525f516d722bce7d19f80b7288d0992c84c2481c5faa"));
String hexValue = Numeric.toHexString(signedMessage);
SignedRawTransaction rawTransaction1 = (SignedRawTransaction) TransactionDecoder.decode(hexValue);
System.out.println(rawTransaction1.getFrom());
HashMap map = new HashMap();
map.put("nonce", Numeric.toHexStringWithPrefix(rawTransaction1.getNonce()));
map.put("v", "0x" + byteToHex(rawTransaction1.getSignatureData().getV()));
map.put("r", Numeric.toHexString(rawTransaction1.getSignatureData().getR()));
map.put("s", Numeric.toHexString(rawTransaction1.getSignatureData().getS()));
map.put("to", rawTransaction1.getTo());
map.put("currency", rawTransaction1.getTo().split("\\.")[0]);
map.put("gasPrice", Numeric.toHexStringWithPrefix(rawTransaction1.getGasPrice()));
map.put("gas", Numeric.toHexStringWithPrefix(rawTransaction1.getGasLimit()));
map.put("commitTime", rawTransaction1.getCommitTime());
map.put("isEntrustTx", rawTransaction1.getIsEntrustTx());
map.put("txEnterType", rawTransaction1.getTxEnterType());
List extraToList = (List) ((List) ((List) rawTransaction1.getExtra_to().get(0)).get(0)).get(2);
List extraTo = new ArrayList();
for (int i = 0, length = extraToList.size(); i < length; i++) {
HashMap<String, String> toMap = new HashMap<String, String>();
toMap.put("to", (String) ((List) extraToList.get(0)).get(0));
toMap.put("value", Numeric.toHexStringWithPrefix((BigInteger) ((List) extraToList.get(0)).get(1)));
extraTo.add(toMap);
}
map.put("extra_to", extraTo);
map.put("data", "0x" + rawTransaction1.getData());
map.put("txType", ((List) ((List) rawTransaction1.getExtra_to().get(0)).get(0)).get(0));
map.put("lockHeight", ((List) ((List) rawTransaction1.getExtra_to().get(0)).get(0)).get(1));
map.put("value", Numeric.toHexStringWithPrefix(rawTransaction1.getValue()));
ManSendTransaction transactionResponse = aiManj.manSendRawTransaction(map).sendAsync().get();
String hash = transactionResponse.getTransactionHash();
System.out.println(hash);

manSign ()

Matrix signatures are calculated using the following formula:
``sign(keccak256(“\x19Matrix Signed Message:\n” + len(message) + message)))`.
By adding a prefix to the message, the result signature can be recognized as a Matrix signature. This prevents malicious DApp from signing arbitrary data, such as transactions, and using signatures to impersonate others.
It should be noted that the address of the signature must be unlocked.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManSign> manSign(java.lang.String arg0, java.lang.String arg1);
Parameter
  • String - MAN Address
  • String - Message to Sign
Return Value

String - Signature

Example
1
2
3
4
5
6
// man_sign
ManSign manSign = aiManj.manSign("MAN.CrsnQSJJfGxpb2taGhChLuyZwZJo","0xdeadbeaf").send();
if(manSign.hasError())
System.out.println("manSign:" + manSign.getError().getMessage());
else
System.out.println("manSign:" + manSign.getSignature().toString());

manGetBlockTransactionCountByNumber ()

Return to the number of transactions sent from a specified address.The block is specified by the block height.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetBlockTransactionCountByNumber> manGetBlockTransactionCountByNumber(org.aimanj.protocol.core.DefaultBlockParameter arg0);
Parameter
  • DefaultBlockParameter
Return Value
  • BigInteger - Number of transactions within a specified block.
Example
1
2
3
// man_getBlockTransactionCountByNumber
ManGetBlockTransactionCountByNumber manGetBlockTransactionCountByNumber = aiManj.manGetBlockTransactionCountByNumber(DefaultBlockParameterName.LATEST).send();
System.out.println("mangetblock transaction count by number:"+manGetBlockTransactionCountByNumber.getTransactionCount());

manAccounts ()

Returns a list of address strings held by the client.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManAccounts> manAccounts();
Parameter

Return Value
  • Array - A list of address strings held by the client.
Example
1
2
ManAccounts manaAccounts = aiManj.manAccounts().send();
System.out.println("manAccounts"+manaAccounts.getResult());

manNewBlockFilter ()

Creates a filter in the node to notify when a new block is generated. To check whether the state changes, call man_getFilterChanges

Parameter

None

Return Value

ManFilter – Filter Number

Example
1
2
ManFilter newBlockFilter = aiManj.manNewBlockFilter().send();
System.out.println("newBlockFilter"+newBlockFilter.getResult());

manUninstallFilter ()

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 manGetFilterChanges call within a certain period of time, it will automatically timeout.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManUninstallFilter> manUninstallFilter(java.math.BigInteger arg0);
Parameter
  • BigInteger-Filter Number
Return Value
  • ManUninstallFilter – Uninstall object.
  • Boolean - Return true if uninstalled successfully, otherwise return false.
Example
1
2
ManUninstallFilter manUninstallFilter = aiManj.manUninstallFilter(new BigInteger("5b54065e0ab48d655ce6a6dea28b7e2c",16)).send();
System.out.println("manUninstallFilter"+manUninstallFilter.getResult());

manNewPendingTransactionFilter ()

Create a filter in the node for notification when pending transactions occur. To check if the state has changed, call manGetFilterChanges.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManFilter> manNewPendingTransactionFilter();
Parameter

None

Return Value
  • ManFilter - Filter Number
Example
1
2
3
// man_newPendingTransactionFilter
ManFilter manNewPendingTransactionFilter = aiManj.manNewPendingTransactionFilter().send();
System.out.println("manNewPendingTransactionFilter"+manNewPendingTransactionFilter.getResult());

manGetEntrustList ()

Returns entrust list for specified authorized account.

Function Prototype
1
public abstract  org.aimanj.protocol.core.Request<?,org.aimanj.protocol.core.methods.response.ManGetEntrustList> manGetEntrustList(java.lang.String arg0);
Parameter
  • STRING- Authorized account address.
Return Value

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
Example
1
2
ManGetEntrustList  manGetEntrustList = aiManj.manGetEntrustList("MAN.5xYzBHrJfXeJi9yQ8Qq8hvm19bU4").send();
System.out.println("manGetEntrustList"+manGetEntrustList.getEntrustList());