All Projects → koczadly → jNano

koczadly / jNano

Licence: MIT license
A comprehensive Java library for the Nano cryptocurrency.

Programming Languages

java
68154 projects - #9 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to jNano

RaiBlocksWebAssemblyPoW
WebAssembly Nanocurrency PoW implementation
Stars: ✭ 33 (+32%)
Mutual labels:  nano, proof-of-work, nano-currency, nanocurrency
nanook
Ruby library for making and receiving payments and managing a nano currency node
Stars: ✭ 17 (-32%)
Mutual labels:  nano, nano-currency, nanocurrency, nano-node
reblocks
React Components for Nano cryptocurrency (formerly RaiBlocks) - including Payments via Brainblocks
Stars: ✭ 21 (-16%)
Mutual labels:  nano, raiblocks, xrb, nanocurrency
rai
🗿 rai is a pythonic client for interacting with Raiblocks nodes
Stars: ✭ 21 (-16%)
Mutual labels:  nano, raiblocks, nano-currency
RaiBlocksPHP
A bunch of PHP methods to build and sign transactions
Stars: ✭ 20 (-20%)
Mutual labels:  nano, nano-currency, nanocurrency
Nano.Net
A .NET library for Nano
Stars: ✭ 19 (-24%)
Mutual labels:  nano, nanocurrency, banano
nano-rs
An implementation of Nano in Rust using Tokio
Stars: ✭ 29 (+16%)
Mutual labels:  nano, nano-currency, nanocurrency
gonano
An implementation of the Nano cryptocurrency in Go
Stars: ✭ 34 (+36%)
Mutual labels:  nano, raiblocks
Nault
⚡ The most advanced Nano wallet with focus on security, speed and robustness
Stars: ✭ 228 (+812%)
Mutual labels:  nano, nanocurrency
nano-vanity
A NANO vanity address generator (supports OpenCL)
Stars: ✭ 83 (+232%)
Mutual labels:  nano, nano-currency
nano-vanity
Vanity address generator for Nano
Stars: ✭ 37 (+48%)
Mutual labels:  nano, raiblocks
nano-update-tx-work
Rebroadcast unconfirmed Nano transactions with higher proof-of-work (PoW) to help restart expired elections.
Stars: ✭ 14 (-44%)
Mutual labels:  nano, nanocurrency
NanoWalletBot
[DISCONTINUED] Open source Telegram bot for Nano currency
Stars: ✭ 52 (+108%)
Mutual labels:  nano, raiblocks
MyNanoNinja
The perfect tool for Nano representatives lists and network statistics
Stars: ✭ 33 (+32%)
Mutual labels:  nano, nanocurrency
Nano Node
Nano is a cryptocurrency
Stars: ✭ 3,336 (+13244%)
Mutual labels:  nano, nanocurrency
nano
API Documentation for Nano.to
Stars: ✭ 65 (+160%)
Mutual labels:  nano, nano-cryptocurrency
nano-modeline
GNU Emacs / N Λ N O Modeline
Stars: ✭ 66 (+164%)
Mutual labels:  nano
Arduino
🚀 Proyectos de todo tipo para arduino utilizando sus sensores y actuadores. 🤖
Stars: ✭ 27 (+8%)
Mutual labels:  nano
cocol
Rapid blockchain prototyping
Stars: ✭ 19 (-24%)
Mutual labels:  proof-of-work
MPCNC-Nano-Estlcam-Shield
Ein CNC Shield für die MPCNC in Verwendung mit Estlcam
Stars: ✭ 60 (+140%)
Mutual labels:  nano

jNano | Java library for Nano

Maven Central

jNano is a Java library used to make integrations with the Nano cryptocurrency simple. This library allows you to interface with the node via RPC requests, and also provides many native tools and utilities so that a node isn't always necessary.

Nano is a crypto-currency which offers instantaneous and fee-less transactions. For more information, visit https://nano.org.


Technical details

  • This library requires Java 8+ (module uk.oczadly.karl.jnano for versions 9+)
  • Fully compatible with clone cryptocurrencies (eg. Banano)
  • Built and managed through Maven
  • List of dependencies

Features

This library provides simple access to the following facilities:


Usage

Download

This project is hosted on Maven Central. You can also download the compiled JAR directly from here.

Maven

<dependency>
    <groupId>uk.oczadly.karl</groupId>
    <artifactId>jnano</artifactId>
    <version>2.20.1</version>
</dependency>

Gradle

dependencies {
    implementation 'uk.oczadly.karl:jnano:2.20.1'
}

Documentation

Examples

RPC Queries [Wiki]

To make queries to an external Nano node through the RPC system, you will need to use the RpcQueryNode class. You can customize these objects even further by constructing using the nested Builder class.

RpcQueryNode rpc = new RpcQueryNode();          // Using localhost:7076
RpcQueryNode rpc = RpcServiceProviders.nanex(); // Using nanex.cc public API

This example will print an account's balance to the console using a synchronous (blocking) call.

// Construct and execute the request, and obtain the response
ResponseBalance balance = rpc.processRequest(new RequestAccountBalance(
        "nano_34qjpc8t1u6wnb584pc4iwsukwa8jhrobpx4oea5gbaitnqafm6qsgoacpiz"));

// Handle the result object however you wish (eg. print the balance)
System.out.println("Account balance: " + balance.getTotal());

WebSockets (listening for blocks) [Wiki]

The following will create a WebSocket listener which connects to port 7078 on localhost. For each new block confirmed by the node, the hash and type will be printed to the console.

NanoWebSocketClient ws = new NanoWebSocketClient(); // Defaults to localhost:7078
ws.connect(); // Connect to the endpoint

// Register a listener (will be called for each new block)
ws.getTopics().topicConfirmedBlocks().registerListener((message, context) -> {
    // Print the hash and type of all confirmed blocks
    System.out.printf("Confirmed block: %s (%s)%n",
            message.getHash(), message.getBlock().getType());
});

// Subscribe to the block confirmations topic
ws.getTopics().topicConfirmedBlocks().subscribeBlocking(new TopicConfirmation.SubArgs()
        .includeBlockContents() // Include block info in messages
        .filterAccounts( // Only receive blocks for these accounts
                "nano_34qjpc8t1u6wnb584pc4iwsukwa8jhrobpx4oea5gbaitnqafm6qsgoacpiz",
                "nano_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est"));

Block Creation [Wiki]

The following sample will create a new state block. The block will be signed using the provided private key, and work will be generated in the JVM using the CPU.

WorkGenerator workGenerator = new CPUWorkGenerator(); // Note: construct once and re-use

StateBlock block = StateBlock.builder()
        .subtype(StateBlockSubType.OPEN)
        .link("BF4A559FEF44D4A9C9CEF4972886A51FC83AD1A2BEE4CDD732F62F3C166D6D4F")
        .balance("123000000000000000000000000")
        .generateWork(workGenerator)
        .buildAndSign("A3293644AC105DEE5A0202B7EF976A06E790908EE0E8CC43AEF845380BFF954E"); // Private key

String hash = block.getHash().toHexString(); // Hashes the block
String blockJson = block.toJsonString(); // Serializes the block to JSON

Dependencies

This project requires the following dependencies, which are included automatically through Maven:


If you found this library useful and would like to support my work, donations may be sent to nano_34qjpc8t1u6wnb584pc4iwsukwa8jhrobpx4oea5gbaitnqafm6qsgoacpiz - any amount would be greatly appreciated :D

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