Coder Social home page Coder Social logo

znn_sdk_java's Introduction

Zenon SDK for Java

build codecov GitHub

Reference implementation for the Zenon SDK for Java. Compatible with the Zenon Alphanet - Network of Momentum Phase 1. It provides a simple integration with any Java based projects.

Requirements

  • JDK 1.8 or higher.

Download and Install

To download and install Zenon SDK you currently have the following options.

JAR

Download the following JARs and add them to your classpath:

  • znn-java-sdk-0.0.4

Usage

Connect Node

import network.zenon.Zenon;

Zenon.getInstance().getClient().connect("ws://nodes.zenon.place:35998");
...
Zenon.getInstance().getClient().close();

Generate wallet

import network.zenon.Zenon;

String wallet = "name";
String passphrase = "secret";

Zenon znn = Zenon.getInstance();

znn.defaultKeyStorePath = 
	znn.getKeyStoreManager().createNew(passphrase, wallet);
znn.defaultKeyStore = 
	znn.getKeyStoreManager().readKeyStore(passphrase, znn.defaultKeyStorePath);

Generate wallet from mnemonic

import network.zenon.Zenon;

String wallet = "name";
String passphrase = "secret";
String mnemonic =
      "route become dream access impulse price inform obtain engage ski believe awful absent pig thing vibrant possible exotic flee pepper marble rural fire fancy";

Zenon znn = Zenon.getInstance();
      
znn.defaultKeyStorePath = 
	znn.getKeyStoreManager().createFromMnemonic(mnemonic, passphrase, wallet);
znn.defaultKeyStore = 
	znn.getKeyStoreManager().readKeyStore(passphrase, znn.defaultKeyStorePath);

Sending a transaction

import network.zenon.Zenon;

String wallet = "name";
String passphrase = "secret";
String mnemonic = "route become dream access impulse price inform obtain engage ski believe awful absent pig thing vibrant possible exotic flee pepper marble rural fire fancy";

Zenon znn = Zenon.getInstance();

znn.defaultKeyStorePath = 
        znn.getKeyStoreManager().createFromMnemonic(mnemonic, passphrase, wallet);
znn.defaultKeyStore = 
        znn.getKeyStoreManager().readKeyStore(passphrase, znn.defaultKeyStorePath);
znn.defaultKeyPair = 
        znn.defaultKeyStore.getKeyPair(); // Use primary address

znn.getClient().connect("ws://192.168.1.112:35998");

znn.send(znn.getEmbedded().getPillar().collectReward());

znn.getClient().close();

API

import network.zenon.Zenon;
import network.zenon.model.primitives.Address;
import network.zenon.model.nom.AccountInfo;

// Connect to node
Zenon.getInstance().getClient()
	.connect("ws://nodes.zenon.place:35998");

// Create an address
Address address = Address
	.parse("z1qq0hffeyj0htmnr4gc6grd8zmqfvwzgrydt402");

// Get account info by address
AccountInfo info = Zenon.getInstance().getLedger()
	.getAccountInfoByAddress(address);

// Close node connection
Zenon.getInstance().getClient().close();

// Print account info
System.out.println("AccountInfo: " + info.toString());

Contributing

Please check CONTRIBUTING for more details.

License

The MIT License (MIT). Please check LICENSE for more information.

znn_sdk_java's People

Contributors

kinggorrin avatar

Watchers

 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.