Skip to content

HPB Wallet and Middleware Interface

BlockGeek edited this page Apr 24, 2019 · 2 revisions

In order to facilitate developers in HPB wallet development and usage, a general API interface introduction is prepared by HPB wallet developers.

1 Hpb Version Controller

1.1 Check app wallet version

Description: check app wallet version

Request

 Request mode: POST 
 Request URL:http://47.75.96.163:9888/HpbComponent/cms/version

Calling example*

[

  "1","0"

]

Request parameter description:

Parameter nmae Necessary Description
1 Yes Device type: (0 for Android or 1 for IOS)
0 Yes parameter 2: language_type(0 for Chinese and 1 for English);

**Return data example: **

[

  "000000",                                                                                                 //response status(000000:success;999999:fail)

  "success",                                                                                                                           //response messgae hint
  {
 
 "map": {},                                                                                                                     //reserved map

  "id": 36,                                                                                                                         //id in current version

  "verNo": "1.0.0",                                                                                                         //version number

  "downloadUrl": "https://fir.im/mw6r",                             
//download address

  "mobileType": 1,                                                                                      //mobile phone:type 0 for Android, 1 for IOS and 2 for others

  "remark": "1.0.2test1120180806111",                       
//remark

  "createTime": 1533547987870,                                      
//creation time seal

  "updateTime": 1534570817329,                                     
//updating time seal

  "state": "1",                                                                                                    //status: 1 for valid and 0 for invalid

  "userId": 1,                                                                                                 //user id

  "isForceFlag": "0",                                                                                    //compulsory update: 1 for yes and 2 for no

  "langType": "0",                                                                                                          //language type: 0 for Chinese, 1 for English

  "verContent": "a1.0.2"                                                         //version content

  }

]

2 Personal Controller

2.1 Check account balance

Description: The app wallet users check the account balance.

**Request Description: **

Request mode: POST 
Request URL:http://47.75.96.163:9888/HpbComponent/personal/getBalance

Calling example:

[

  "0x09a0e8893efd605e6aaae9b0c8285a3f16e5f198"

]

Request parameter description:

Parameter name Necessary Description
Parameter 1 Yes (address starts with 0x, 42-digit hash)

Data return example

[

  "000000",                                                                                                                      //Response status(000000:success;999999:fail)

  "success",                                                                                                                                              //Response messgae hint

  0                                                                                                   //Balance

]

2.2 Check account nonce

Description: The app wallet users check the account nonce.

Request Description:

Request mode: POST 
URL Request URL:http://47.75.96.163:9888/HpbComponent/personal/getNonce

Calling example

[

  "0x09a0e8893efd605e6aaae9b0c8285a3f16e5f198"

]

Request parameter description:

Parameter name Necessary Description
Parameter 1 Yes (address starts with 0x, 42-digit hash)

Return data example

[

   "000000",                                                                                                                     //Response status(000000:success;999999:fail)

  "success",                                                                                                                                              //Response messgae hint

  {
  "gasLimit": "50000",                                                                               // gasLimit

  "nonce": 0,                                                                                                 //nonce

  "gasPrice": "18000000000"                                                                 // gasPrice  
  }                                                                                  

]

3 Personal Controller

3.1 Check transaction

Description: The app wallets check transaction based on transaction hash.

Request Description:

Request mode: POST 
Request URL:http://47.75.96.163:9888/HpbComponent/transaction/getTransactionByHash

Calling example

[

  " 0x78a7012f467035e4ca1a8f6dffe6e138e1a24e591ba4945de5ef74bbcb69cd63"

]

Request parameter description:

Parameter name Necessary Description
Parameter 1 Yes Transaction hash(address starts with 0x, 64-digit hash)

Return data example

[

  "000000",                                                                                  //Response status(000000:success;999999:fail)

  "success",                                                                                                                                              //Response messgae hint

  {

 "hash": "0xdd19d1946bc000294d5d5e2ee01943bdd07165576460bd20e739964029214071",                                                                                                                        //transaction hash

  "nonce": 2,                                                             //nonce

  "blockHash": "0x638055808a31f15e0854baca5e688c4d8e15910c06c4ea56a389f567a00d8671",                                                                                                                        //current hash 

"blockNumber": 150318,                                      
//current block number

 "transactionIndex": 0,                                        
//transaction sequence number in the block

  "from": "0x847af04fbd21a909726cf00aaa06acd820035d5a",                                                       //transaction initiator

  "to": "0x3795435afaec3bfb2388a1e2ef58108f564d3e07",                      
//transaction receiver

  "value": 0,                                                                                //transaction amount

  "gasPrice": 18000000000,                                                 
// gasPrice

  "gas": 90000,                                                        
 // gas

  "input": "0x7b0d0a09226772616365506572696f64223a20223135222c0d0a092270726548617368223a2022222c0d0a092263757374636453616c6c6572223a2022313030373431222c0d0a0922696e7365727444617465223a2022323031382d30382d3136222c0d0a09226d656d6f223a2022222c0d0a0922636e616d6553656c6c6572223a2022e58d83e5b29be6b996e69e97e69ca8e58aa0e5b7a5e69c89e99990e585ace58fb8222c0d0a09226275737354797065223a202231323330303130222c0d0a092264656274456e64223a2022323031382d31302d3135222c0d0a0922646561644c696e65223a2022323031382d31302d3330222c0d0a092262696c6c7354797065223a20223031222c0d0a09226375737463644275796572223a2022313030373433222c0d0a092262696c6c73416d6f756e74223a202233303030302e3030222c0d0a092272656d61696e696e67416d6f756e74223a202233303030302e3030222c0d0a092262696c6c7344617465223a2022323031382d30382d3136222c0d0a09226d617374436f6e746e6f223a2022474e424c32303138303831363030303031222c0d0a092262696c6c734e6f223a2022505a485432303138303832313031222c0d0a092262696c6c73416d6f756e7456696577223a202233303030302e3030222c0d0a092262757373436f6e74636f6465223a20225357485432303138303832313031222c0d0a09226167696e67223a20223630222c0d0a0922636e616d654275796572223a2022e6b599e6b19fe697b6e997b4e69e97e7a791e68a80e69c89e99990e8b4a3e4bbbbe585ace58fb8222c0d0a0922737461747573223a20223031220d0a7d",                                                          
  //(input field)
  //Information attached to the transaction (input field)
   "creates": null,                                                      

   "publicKey": null,

   "raw": null,

   "r": "0xe417129af6776b6985ef95b92ef25b4e1c0025eb387b8e097aa182f89de889c7",

   "s": "0x5193ba9a5378f7d19f72a3e717dd5096fbc06f3a79c358c790475b385fe30225",

    "v": 37,

    "transactionIndexRaw": "0x0",

    "blockNumberRaw": "0x24b2e",

    "nonceRaw": "0x2",

    "valueRaw": "0x0",

    "gasPriceRaw": "0x430e23400",

    "gasRaw": "0x15f90"

  }                                                                

]

3.2 Check Transaction History

Description: The app wallet users check transaction history of the local account.

Request Description:

Request mode: POST 
URL Request URL:http://47.75.96.163:9888/HpbComponent/transaction/getTransactionHistory



Calling example:

[

  " 0x847af04fbd21a909726cf00aaa06acd820035d5a","0","1"

]

Request parameter description:

Parameter name Necessary Description
Parameter1 Yes address (address starts with 0x, 42-digit hash)
Parameter2 Yes Transaction type (0 for all, 1 for send and 2 for receive
Parameter3 Yes Page number >0

Return data example

[

  "000000",                                                                                  

//Response status(000000:success;999999:fail)

  "success",                                                                                                                                              

//Response messgae hint

  {

 "pageNum": 1,                                                                        //current page number

 "pageSize": 10,                                                                        //current page size

 "size": 6,                                                                                   //data size

 "startRow": 1,                                                                          //start row

 "endRow": 6,                                                                            //end row

  "total": 6,                                                                                  //total records

  "pages": 1,                                                                                //total pages

  "list": [                                                                                       //data list

   {

  "map": {},                                                                                //reserved map

  "transactionHash": "0xf467c92777a820cb92f75556b5d06f69b635197c997b910c7dc4219a83f85ef9",
                                                                                                               //transaction hash

  "fromAccount": "0x847af04fbd21a909726cf00aaa06acd820035d5a",             

//initiator

 "toAccount": "0x3795435afaec3bfb2388a1e2ef58108f564d3e07",                    

//receiver

  "nonce": 4,                                                                                  //nonce

 "tValue": "0",                                                                            //amount

  "gas": "90000",                                                                      //gas

 "gasPrice": "18000000000",                                              	 //gasPrice

 "status": "0x1",                                                                    //status

 "blockHash": "0x9163f7ff6b4611b3bd6957c4560ff3a45d4cc31f85753f6ec6819bd33d67eb34",                                                                                                   //current hash

 "blockNumber": 150612,                                                  
 //block number

 "transactionIndex": null,                                                    //transaction sequence number in the block

 "tTimestap": 1534820055,                                                
//time stamp

  "gasUsed": "633",                                                               //gas fees

 "remark": null,                                                                     //

 "tInput": null,                                                                       //input parameter field

 "actulTxFee": "11394000000000"

   }      

],

  "prePage": 0,                                                                             //previous page

  "nextPage": 0,                                                                           //next page

  "isFirstPage": true,                                                                   //is first page?

  "isLastPage": true,                                                                   //is last page?

  "hasPreviousPage": false,                                                      //has previous page?

   "hasNextPage": false,                                                             //has next page?

   "navigatePages": 8,                                                                 //maximum pages

   "navigatepageNums": [         //page field                                                 
      1
    ],

    "navigateFirstPage": 1,                                                           	//first page

    "navigateLastPage": 1,                                                           	//last page

    "firstPage": 1,                                                                          	//first page

    "lastPage": 1                                                                            	//last page

  }                                              

]

3.3 Send transaction

Description: The app wallet users initiate transaction.

Request Description

Request mode: POST 
Request URL:http://47.75.96.163:9888/HpbComponent/transaction/sendRawTransaction

Calling example

[

  " 0xf467c92777a820cb92f75556b5d06f69b635197c997b910c7dc4219a83f85ef9"

]

Request parameter description:

Parameter name Necessary Description
Parameter 1 Yes Hash data with signature (hash data starts with 0x, hexadecimal data, tests abnormalites)

Return data example:

[
  "000000",                                                                                  //Response status(000000:success;999999:fail)

  "success",                                                                                                                                              //Response messgae hint

  {
  "hash": "0xdd19d1946bc000294d5d5e2ee01943bdd07165576460bd20e739964029214071",                                                                                                                                                          //transaction hash

  "nonce": 2,                                                                                                  //nonce

  "blockHash": null,                                                                  //transaction in package, block number is blank

  "blockNumber": null,                                                            //transaction in package, block number is blank

  "transactionIndex": null,                                                      //transaction in package

  "from": "0x847af04fbd21a909726cf00aaa06acd820035d5a",                                  //initiator

  "to": "0x3795435afaec3bfb2388a1e2ef58108f564d3e07",                      
//receiver

 "value": 0,                                                                                                  //value

 "gasPrice": 18000000000,                                                  //gasPrice

 "gas": 90000,                                                                          // gas number

 "input": null,                                                                            // input field

 "creates": null,  
// null

  "publicKey": null,                                                                     // null

  }                                              

]

 

Clone this wiki locally