Giter VIP home page Giter VIP logo

caver-java-ext-kas's Introduction

caver-java-ext-kas

caver-java-ext-kas is caver-java's extension library for using KAS(Klaytn API service).

Table of contents

Installation

maven

<dependency>
  <groupId>xyz.groundx.caver</groupId>
  <artifactId>caver-java-ext-kas</artifactId>
  <version>X.X.X</version>
  <type>pom</type>
</dependency>
<dependency>
  <groupId>xyz.groundx.caver</groupId>
  <artifactId>caver-java-ext-kas</artifactId>
  <version>X.X.X-android</version>
  <type>pom</type>
</dependency>

gradle

implementation 'xyz.groundx.caver:caver-java-ext-kas:X.X.X'
implementation 'xyz.groundx.caver:caver-java-ext-kas:X.X.X-android'

You can find latest caver-java-ext-kas version at release page.

caver-java-ext-kas requires at minimum Java 8+.

Getting Started

Initialize API

For now, you can use Node API, Token History API, Wallet API and Anchor API provided by KAS through this library. To use KAS API, the following items are required.

  • Access key, secret access key issued by KAS console.
  • Base URL to use the API provided by KAS.
  • The Klaytn network chain id to be used.

You can activate KAS API by writing code as below.

initKASAPI() function can initialize all API provided by KAS.

CaverExtKAS caver = new CaverExtKAS();
caver.initKASAPI(chain_id, accessKey, secretAccessKey);

If you want to initialize API each other, you can use initialize***API() instead.

CaverExtKAS caver = new CaverExtKAS();
caver.initNodeAPI(chain ID, accessKey, secretAccessKey);
caver.initWalletAPI(chain ID, accessKey, secretAccessKey);
caver.initTokenHistoryAPI(chain ID, accessKey, secretAccessKey);
caver.initAnchorAPI(chain ID, accessKey, secretAccessKey);

Use Node API

You can now use Node API through com.klaytn.caver.rpc.Klay class in caver-java library. You can send a Node API request to the KAS as shown below and check the results.

public void getBlockNumber() {
    try {
        Quantity response = caver.rpc.klay.getBlockNumber().send();
    } catch(Exception e) {
        // Handle error.
    }

Use Token History API

You can use Token History API through caver-java-ext-kas. You can send a Token History API request to the KAS as shwon below.

public void getFTContractList() {
    try {
        PageableFtContractDetails details = caver.kas.tokenHistory.getFTContractList();
        assertNotNull(details);
    } catch (ApiException e) {
        //Handle error
    }
}

You can find query options required each Token History API in KAS Docs. For defining query options, you can use TokenHistoryQueryOptions class.

TokenHistoryQueryOptions options = new TokenHistoryQueryOptions();
options.setCaFileter(..);
options.setKind(..);
options.setRange(..);
options.setSize(..);
options.setSize(..);
options.setStatus(..);
options.setType(..);
public void getNFTContractList() {
    try {
        TokenHistoryQueryOptions options = new TokenHistoryQueryOptions();
        options.setStatus("processing");
        PageableNftContractDetails details = caver.kas.tokenHistory.getNFTContractList(options);
        assertNotNull(details);
    } catch (ApiException e) {
        //handle error
    }
}

Use Wallet API

You can use Wallet API through caver-java-ext-kas. You can send a Wallet API request to the KAS as shwon below.

public void createAccount() {
    try {
        Account account = caver.kas.wallet.createAccount();
        assertNotNull(account);
    } catch (ApiException e) {
        //handle error
    }
}

You can find query options required each Wallet API in KAS Docs. For defining query options, you can use WalletQueryOptions class.

WalletQueryOptions options = new WalletQueryOptions();
options.setSize();
options.setCursor();
options.setFromTimestamp();
options.setToTimesatamp();

Use Anchor API

You can use Anchor API through caver-java-ext-kas. You can send a Anchor API request to the KAS as shwon below.

public void getOperators() {
    try {
        Operators res = caver.kas.anchor.getOperators();
        assertNotNull(res);
    } catch(ApiException e) {
        //handle error
    }
}

You can find query options required each Anchor API in KAS Docs. For defining query options, you can use AnchorQueryOptions class.

AnchorQueryOptions options = new AnchorQueryOptions();
options.setSize();
options.setCursor();
options.setFromTimestamp();
options.setToTimesatamp();

caver-java-ext-kas's People

Contributors

whoisxx avatar

Watchers

James Cloos 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.