This repo provide simple HTTP Restful API for developers to send did raw data to elastos did side chain.
In project directory, use maven command:
$uname mvn clean compile packageIf there is build success, Then the package did.chain.agent-0.0.1.jar will be in target directory.
In project directory, create configuration file from the template:
$ pushd src/main/resources
$ cp -v application.properties.in application.properties
$ popdFirst create database table use sql file in project: block_chain_agent.sql
Change spring.datasource to your database.like:
spring.datasource.url=jdbc:mariadb://localhost:3306/up_chain_wallets?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=12345678
spring.datasource.driver-class-name=org.mariadb.jdbc.DriverChange "node.didPrefix" to your did side chain node url.
Change "wallet.sum" to change the amount of the wallets to be used to up chain. the more up chain wallets the more up chain transaction at the same time and the more resource to be used. So we recommend the number is bigger than 100 and less than 1000.
Copy did.chain.service-0.0.1.jar to your deploy directory. then use jar command to run this spring boot application.
$uname java -jar did.chain.agent-0.0.1.jar/api/v1/upchain/deposit/addressAll the up chain fee go from deposit wallet, so you will get deposit address to renewal the system.
For example: We get from our local did chain service request like this:
http://localhost:8093/api/1/blockagent/upchain/deposit/addressIf Success, we will get response like:
{
"result": "EZdDnKBRnV8o77gjr1M3mWBLZqLA3WBjB7",
"status": 200
}The "result" is deposit wallet address, which need to have enough ela(>10ela) to pay the up chain fee.
/api/1/blockagent/upchain/wallets/renewalAfter you renewal the deposit wallet. You should call this api to renewal the really work wallets(up chain wallet) from the deposit wallet, to make sure the up chain recording be success.
For example: We post to our local did chain service request like this:
http://localhost:8093/api/1/blockagent/upchain/wallets/renewalwith header:
[{"key":"Content-Type","value":"application/json","description":"","enabled":true}]and put the transfer ela in body.
{
"ela": "10.0"
}If Success, we will get response like:
{
"result": "a8965892e49a9f285bfd61059b9766b54f98cd0f53bf0548f17860acc9a71964",
"status": 200
}The "result" is txid, which is the transaction id of deposit wallet transfer to up chain wallets.
/api/1/blockagent/upchain/dataFor example: I have raw data (which can be created by API:ElaDidService.packDidRawData):
Then we post to our local did chain service request like this:
http://localhost:8093/api/1/blockagent/upchain/datawith header:
[{"key":"Content-Type","value":"application/json","description":"","enabled":true}]and the raw data in post body of curse.
If Success, we will get response like:
{
"result": "a8965892e49a9f285bfd61059b9766b54f98cd0f53bf0548f17860acc9a71964",
"status": 200
}The "result" is txid, which is the record transaction id.
/api/v1/upchain/restGet rest of deposit and working wallets.
For example: We get from our local did chain service request like this:
http://localhost:8093/api/1/blockagent/upchain/restIf Success, we will get response like:
{
"result": {
"DepositRest": 9.999597,
"WorkingWalltesRest": 11.099888999999978
},
"status": 200
}HTTP: POST URL : /api/1/blockagent/upchain/switch data:{ "service":true, "task":false } return: 成功:{"status":200} 失败:{"status":400, "message":"err msg"}