Code Monkey home page Code Monkey logo

javasdk's Introduction

LITESDK

License: LGPL v3 Build Status Coverage Status

Get started

Install

Maven

<dependency>
    <groupId>cn.hyperchain</groupId>
    <artifactId>litesdk</artifactId>
    <version>x.x.x</version>
</dependency>

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.

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.

ContractService contractService = ServiceManager.getContractService(providerManager);
AccountService accountService = ServiceManager.getAccountService(providerManager);

3. Create account

Account can be used to sign transaction.

Account account = accountService.genAccount(Algo.SMRAW);

4. Build transaction

Transaction builder can create different transaction by different style of initialization.

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

ReceiptResponse receiptResponse = contractService.deploy(transaction).send().polling();

6. Decode result

Decode result to specific type.

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.

javasdk's People

Contributors

kaiktang avatar hafeidejiangyou avatar liuxiaomeig avatar kikyo-ky-co avatar terasum avatar jiaohu avatar taoyq1988 avatar zhengbaic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.