Skip to content

elastos/Elastos.ORG.BlockchainAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elastos.ORG.BlockchainAgent

Summary

This repo provide simple HTTP Restful API for developers to send did raw data to elastos did side chain.

Build with maven

In project directory, use maven command:

$uname mvn clean compile package

If there is build success, Then the package did.chain.agent-0.0.1.jar will be in target directory.

Configure project properties

In project directory, create configuration file from the template:

$ pushd src/main/resources
$ cp -v application.properties.in application.properties
$ popd

Configure database

First 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.Driver

Configure did side chain address

Change "node.didPrefix" to your did side chain node url.

Configure did up chain wallets sum

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.

Run

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

Web Service APIs

Get deposit address for renewal

/api/v1/upchain/deposit/address

All 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/address

If 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.

Renewal all the up chain wallets

/api/1/blockagent/upchain/wallets/renewal

After 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/renewal

with 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.

Up raw data to side chain

/api/1/blockagent/upchain/data

For 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/data

with 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.

Get rest of wallets

/api/v1/upchain/rest

Get 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/rest

If Success, we will get response like:

{
    "result": {
        "DepositRest": 9.999597,
        "WorkingWalltesRest": 11.099888999999978
    },
    "status": 200
}

Turn on/off up data service and timer task

HTTP: POST URL : /api/1/blockagent/upchain/switch data:{ "service":true, "task":false } return: 成功:{"status":200} 失败:{"status":400, "message":"err msg"}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages