https://github.com/hyperchain/javasdk
the Java SDK for hyperchain (developing)
https://github.com/hyperchain/javasdk
blockchain hyperchain java sdk
Last synced: 4 months ago
JSON representation
the Java SDK for hyperchain (developing)
- Host: GitHub
- URL: https://github.com/hyperchain/javasdk
- Owner: hyperchain
- License: lgpl-3.0
- Created: 2019-02-25T06:52:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-21T11:38:03.000Z (over 2 years ago)
- Last Synced: 2025-07-30T13:59:45.263Z (6 months ago)
- Topics: blockchain, hyperchain, java, sdk
- Language: Java
- Homepage: http://docs.hyperchain.cn
- Size: 1.73 MB
- Stars: 67
- Watchers: 6
- Forks: 36
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# LITESDK
[](https://www.gnu.org/licenses/lgpl-3.0)
[](https://travis-ci.org/hyperchain/javasdk)
[](https://coveralls.io/github/hyperchain/javasdk?branch=master)
## Get started
### Install
Maven
```
cn.hyperchain
litesdk
x.x.x
```
Gradle
```
compile group: 'cn.hyperchain', name: 'litesdk', version: 'x.x.x'
```
It's better to use latest sdk to send transaction, now it will be compatible with hyperchain 1.0 and 2.0
### Usage
#### 1. build provider manager
Provider can be expanded by user, we support default http provider.
Then create provider manager.
```java
String DEFAULT_URL = "localhost:8081";
DefaultHttpProvider defaultHttpProvider = new DefaultHttpProvider.Builder().setUrl(DEFAULT_URL).build();
ProviderManager providerManager = ProviderManager.createManager(defaultHttpProvider);
```
#### 2. Build service
Create different services by specific provider manager, service will provide some function.
```java
ContractService contractService = ServiceManager.getContractService(providerManager);
AccountService accountService = ServiceManager.getAccountService(providerManager);
```
#### 3. Create account
Account can be used to sign transaction.
```java
Account account = accountService.genAccount(Algo.SMRAW);
```
#### 4. Build transaction
Transaction builder can create different transaction by different style of initialization.
```java
// deploy
Transaction transaction = new Transaction.HVMBuilder(account.getAddress()).deploy("hvm-jar/hvmbasic-1.0.0-student.jar").build();
transaction.sign(account);
// invoke
Transaction transaction1 = new Transaction.HVMBuilder(account.getAddress()).invoke(receiptResponse.getContractAddress(), new StudentInvoke()).build();
```
#### 5. Get response
Service will return a Request, user can use Request to get specific Response by interface.
```java
ReceiptResponse receiptResponse = contractService.deploy(transaction).send().polling();
```
#### 6. Decode result
Decode result to specific type.
```java
Decoder.decodeHVM(receiptResponse1.getRet(), String.class);
```
## Issue
If you have any suggestions or idea, please submit issue in this project!
## Doc
If you want to know more about LiteSDK, you can read manual at [here](docs/hyperchain_litesdk_document.md).