All Projects → everitoken → Evt4j

everitoken / Evt4j

Licence: mit
Official Java SDK for everiToken public chain. https://www.everitoken.io

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Evt4j

Js Stellar Sdk
Main Stellar client library for the Javascript language
Stars: ✭ 488 (+96.77%)
Mutual labels:  blockchain, sdk
Javasdk
the Java SDK for hyperchain (developing)
Stars: ✭ 35 (-85.89%)
Mutual labels:  blockchain, sdk
Cakeshop
An integrated development environment and SDK for Ethereum-like ledgers
Stars: ✭ 491 (+97.98%)
Mutual labels:  blockchain, sdk
Lisk Sdk
🔩 Lisk software development kit
Stars: ✭ 2,767 (+1015.73%)
Mutual labels:  blockchain, sdk
Flow Go Sdk
Tools for building Go applications on Flow 🌊
Stars: ✭ 109 (-56.05%)
Mutual labels:  blockchain, sdk
Decentralized Internet
A SDK/library for decentralized web and distributing computing projects
Stars: ✭ 406 (+63.71%)
Mutual labels:  blockchain, sdk
Bitgosdk Php
BitGo SDK written in PHP
Stars: ✭ 22 (-91.13%)
Mutual labels:  blockchain, sdk
Py Stellar Base
Stellar client library for the Python language
Stars: ✭ 273 (+10.08%)
Mutual labels:  blockchain, sdk
Stellar Ios Mac Sdk
Stellar SDK for iOS & macOS - Swift, Stellar, Horizon, Soneso
Stars: ✭ 92 (-62.9%)
Mutual labels:  blockchain, sdk
Solana Web3.js
Solana JavaScript SDK
Stars: ✭ 85 (-65.73%)
Mutual labels:  blockchain, sdk
Evtjs
API Binding (SDK) for the everiToken blockchain.
Stars: ✭ 697 (+181.05%)
Mutual labels:  blockchain, sdk
Hanzo.js
🚀 Hanzo JavaScript SDK. Develop cutting-edge decentralized applications.
Stars: ✭ 128 (-48.39%)
Mutual labels:  blockchain, sdk
Web Sdk
Portis Web SDK
Stars: ✭ 65 (-73.79%)
Mutual labels:  blockchain, sdk
Hydro Scaffold Dex
A Decentralized Exchange Scaffold - launch a DEX in minutes
Stars: ✭ 112 (-54.84%)
Mutual labels:  blockchain, sdk
Java Stellar Sdk
Stars: ✭ 146 (-41.13%)
Mutual labels:  blockchain, sdk
Wiredash Sdk
Interactive user feedback tool for Flutter 🎉
Stars: ✭ 232 (-6.45%)
Mutual labels:  sdk
Awesome Blockchain Kor
<블록체인의 정석>, <하이퍼레저 블록체인 개발> 소스코드 및 참고자료 저장소
Stars: ✭ 243 (-2.02%)
Mutual labels:  blockchain
Go Seele
Seele is an open source blockchain project which consists of advanced sharding technology and our innovative anti-asic MPoW consensus algorithm. The ONLY official website is
Stars: ✭ 234 (-5.65%)
Mutual labels:  blockchain
Agregore Browser
A minimal browser for the distributed web
Stars: ✭ 229 (-7.66%)
Mutual labels:  blockchain
Rhizobia p
PHP安全SDK及编码规范
Stars: ✭ 244 (-1.61%)
Mutual labels:  sdk

evt4j

Official Java SDK for everiToken public chain.

This SDK also has an example package set up, which lists various useful code examples for quick references on how to interact with everiToken public chain.

Install

use with Maven project

In project pom.xml file

You can also check evt4j-maven-project-demo for insights on how to use evt4j with maven project

<dependencies>
    <dependency>
        <groupId>io.everitoken.sdk</groupId>
        <artifactId>chain-sdk</artifactId>
        <version>1.4.6</version>
    </dependency>
</dependencies>

use with Gradle project

In project build.gradle file

You can also check evt4j-gradle-project-demo for insights on how to use evt4j with gradle project

dependencies {
    // other dependencies
    implementation 'io.everitoken.sdk:chain-sdk:1.4.6'
}

other

Build jar with all the dependencies, run the following command

mvn clean compile assembly:single

It will generate jar with all dependencies under target folder

Use maven command to install jar as dependency

$ mvn install:install-file -Dfile=path/to/jar/file \
                           -DgroupId=io.everitoken.sdk \
                           -DartifactId=chain-sdk \
                           -Dversion=version \
                           -Dpackaging=jar

Usage overview

Here is the code example which highlights the common usage of the SDK.

Click to see full code example
package io.everitoken.sdk.java.example;

import java.util.Arrays;
import java.util.List;

import io.everitoken.sdk.java.Address;
import io.everitoken.sdk.java.Api;
import io.everitoken.sdk.java.Asset;
import io.everitoken.sdk.java.PrivateKey;
import io.everitoken.sdk.java.PublicKey;
import io.everitoken.sdk.java.abi.TransferFungibleAction;
import io.everitoken.sdk.java.dto.NodeInfo;
import io.everitoken.sdk.java.dto.TransactionData;
import io.everitoken.sdk.java.exceptions.ApiResponseException;
import io.everitoken.sdk.java.param.NetParams;
import io.everitoken.sdk.java.param.TestNetNetParams;
import io.everitoken.sdk.java.provider.KeyProvider;
import io.everitoken.sdk.java.service.TransactionConfiguration;
import io.everitoken.sdk.java.service.TransactionService;

class BasicUsage {
public static void main(String[] args) {
        // generate a key pair
        PrivateKey privateKey = PrivateKey.randomPrivateKey();
        PublicKey publicKey = privateKey.toPublicKey();

        // construct a NetParams to interact with the node
        NetParams netParams = new TestNetNetParams();

        // init Api instance
        Api api = new Api(netParams);

        // get information of the node
        try {
            NodeInfo info = api.getInfo();
            System.out.println(info.getChainId());
        } catch (ApiResponseException e) {
            System.out.println(e.getRaw());
        }

        // get balance of all fungible tokens (for example: EVT Token) for a public key
        try {
            // do something with balance list
            List<Asset> balances = api.getFungibleBalance(Address.of(publicKey));
        } catch (ApiResponseException e) {
            System.out.println(e.getRaw());
        }

        // transfer fungible tokens to others

        // construct an action to represent the transfer
        TransferFungibleAction transferFungibleAction = TransferFungibleAction.of("2.00002 S#20",
                "EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND",
                "EVT8aNw4NTvjBL1XR6hgy4zcA9jzh1JLjMuAw85mSbW68vYzw2f9H", "testing java");

        try {
            // init transaction service with net parameters
            TransactionService transactionService = TransactionService.of(netParams);

            // init transaction configuration
            TransactionConfiguration trxConfig = new TransactionConfiguration(1000000, publicKey,
                    KeyProvider.of(privateKey.toWif()));

            // push this action to the node and get back an transaction
            TransactionData txData = transactionService.push(trxConfig, Arrays.asList(transferFungibleAction));
            System.out.println(txData.getTrxId());
        } catch (ApiResponseException ex) {
            System.out.println(ex.getRaw());
        }
    }
}

PrivateKey usage

static randomPrivateKey

Click to see code example
import io.everitoken.sdk.java.PrivateKey;

PrivateKey privateKey = PrivateKey.randomPrivateKey();

static seedPrivateKey

Click to see code example
import io.everitoken.sdk.java.PrivateKey;

PrivateKey seedPrivateKey = PrivateKey.seedPrivateKey("a random string");

static of

Click to see code example
import io.everitoken.sdk.java.PrivateKey;

PrivateKey privateKeyFromWif = PrivateKey.of("5J1by7KRQujRdXrurEsvEr2zQGcdPaMJRjewER6XsAR2eCcpt3D");

static isValidPrivateKey

Click to see code example
import io.everitoken.sdk.java.PrivateKey;

boolean valid = PrivateKey.isValidPrivateKey("5J1by7KRQujRdXrurEsvEr2zQGcdPaMJRjewER6XsAR2eCcpt3D");

toPublicKey

Click to see code example
import io.everitoken.sdk.java.PrivateKey;
import io.everitoken.sdk.java.PublicKey;

PrivateKey privateKey = PrivateKey.randomPrivateKey();
PublicKey publicKey = privateKey.toPublicKey();

toWif

Click to see code example
import io.everitoken.sdk.java.PrivateKey;

PrivateKey privateKey = PrivateKey.randomPrivateKey();
System.out.println(privateKey.toWif());

Api usage

By instantiate an Api instance, you will be able to use it to interact with the specified remote node.

Refer to ApiExample.java in our example package for detailed code examples.

Action usage

An Action in an instruction to perform a given task on everiToken public chain. In order to send Action, the workflow is to:

  1. construct the given action locally
  2. instantiate an TransactionService to push the action (or actions) to the chain

Refer to example package for more code examples of each Action.

Here is the code example showing how to create a domain on everiToken public chain
// instantiate net parameter, can also be main net
final NetParams netParam = new TestNetNetParams();

// specify the content of the action
final String actionData = "...";
final JSONObject json = new JSONObject(actionData);

// use json data to build the NewDomainAction, alternatively you can also build with other constructs, check NewDomainAction class for more details
final NewDomainAction newDomainAction = NewDomainAction.ofRaw(json.getString("name"), json.getString("creator"),
        json.getJSONObject("issue"), json.getJSONObject("transfer"), json.getJSONObject("manage"));

try {
    // init *TransactionService* with a net parameter
    TransactionService transactionService = TransactionService.of(netParam);

    // construct *TransactionConfiguration*
    TransactionConfiguration trxConfig = new TransactionConfiguration(1000000,
            PublicKey.of("EVT6Qz3wuRjyN6gaU3P3XRxpnEZnM4oPxortemaWDwFRvsv2FxgND"),
            KeyProvider.of("5J1by7KRQujRdXrurEsvEr2zQGcdPaMJRjewER6XsAR2eCcpt3D"));

    // push the action to chain. Note: you can also pass multiple actions here
    TransactionData txData = transactionService.push(trxConfig, Arrays.asList(newDomainAction));

    // get the transaction data
    System.out.println(txData.getTrxId());
} catch (final ApiResponseException ex) {
    System.out.println(ex.getRaw());
}

EvtLink usage

EvtLink generation

EvtLink is the place to generate and parse QR Codes using EVT Link's syntax. EVT Link can be used for everiPass, everiPay, Address Code for Receiver.

For further information, read Documentation for EvtLink / everiPass / everiPay.

static getEvtLinkForEveriPass

Generate EvtLink for everiPass.

Click to see code example
NetParams netParams = new TestNetNetParams();

// Init new EvtLink instance with given net param
EvtLink evtLink = new EvtLink(netParams);

// make sure the domain and token you use exist and has correct authorize keys
// replace "domainName" and "tokenName" with your custom values
EvtLink.EveriPassParam everiPassParam = new EvtLink.EveriPassParam(true, "domainName", "tokenName");

String passText = evtLink.getEvtLinkForEveriPass(everiPassParam,
        SignProvider.of(KeyProvider.of("5J1by7KRQujRdXrurEsvEr2zQGcdPaMJRjewER6XsAR2eCcpt3D")));

// will print out the content of evt link
System.out.println(passText);

try {
    // will print PNG image data url, e.g. "data:image/png;base64,..."
    System.out.println(Utils.getQrImageDataUri(passText));
} catch (Exception e) {
    // handle exception creating QR image data
}

static getEvtLinkForEveriPay

Generate a EvtLink for EveriPay is similar to the one shown above for EveriPass.

Click to see code example
String uniqueLinkId = EvtLink.getUniqueLinkId();
int symbolId = 1;
int maxAmount = 100;

// init Api connection to the node
NetParams netParams = new TestNetNetParams();

// init evtLink instance with api instance
EvtLink evtLink = new EvtLink(netParams);

// init everiPayParam which representing the everiPay action, which contains
//      - symbolId (e.g. 1 for Evt),
//      - uniqueLinkId (which can be generated with the helper function (getUniqueLinkId) from EvtLink class),
//      - maxAmount
EvtLink.EveriPayParam everiPayParam = new EvtLink.EveriPayParam(symbolId, uniqueLinkId, maxAmount);

// the string generated here can be encoded in to QR code, refer to example "getEvtLinkForEveriPay" for code snippet
String payText = evtLink.getEvtLinkForEveriPay(everiPayParam,
        SignProvider.of(KeyProvider.of("5J1by7KRQujRdXrurEsvEr2zQGcdPaMJRjewER6XsAR2eCcpt3D")));

Deploy

  • setup user settings.xml for maven, where username and password should be specified
  • obtain the gpg key and password
  • run mvn clean javadoc:jar deploy which will deploy a stage version
  • run mvn nexus-staging:release

use master mvn clean compile assembly:single to build with all dependencies

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].