• This repository has been archived on 07/Jun/2023
  • Stars
    star
    144
  • Rank 246,584 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

IOTA Java API Library. Find documentation on


The official Java client library for interacting with the legacy Tangle (deprecated since Chrysalis)

Developer documentation portal

Auto-generated docs Discord StackExchange Apache 2.0 license Supported IRI API endpoints Code quality Latest release Build status

About β—ˆ Prerequisites β—ˆ Installation β—ˆ Getting started β—ˆ API reference β—ˆ Examples β—ˆ Change logs β—ˆ Supporting the project β—ˆ Joining the discussion


Deprecation warning

This java client is no longer usable in the new Chrysalis network. Please use the Java bindings generated for iota.rs. They can be found here

About

This was the official Java client library, which allows you to do the following:

  • Create transactions
  • Read transactions
  • Sign transactions
  • Generate addresses

This is beta software, so there may be performance and stability issues. Please report any issues in our issue tracker.

Prerequisites

To use the IOTA Java client library, your computer must have the following minimum requirement:

  • Java 6 (or higher)

Installation

The IOTA Java client library is available on [jitpack.io][jitpack].

To install the IOTA Java client library and its dependencies, you can use one of the following options:

  • Download the library with Gradle
  • Download the library with Maven
  • Download the library manually

Gradle

  1. Add the following repository to your root build.gradle file (not your module build.gradle file):

    allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
  2. Add the following dependency to your module build.gradle file:

    dependencies {
        compile 'com.github.iotaledger:iota-java:1.0.0-beta8'
    }

Maven

Through Maven central

  1. Add the following repository to your root pom.xml file:
    <dependency>
        <groupId>org.iota</groupId>
        <artifactId>jota</artifactId>
        <classifier>jar-with-dependencies</classifier>
        <version>1.0.0-beta9</version>
    </dependency>

Through Jitpack

  1. Add the following repository to your root pom.xml file:

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
  2. Add the following dependency to your module pom.xml file:

    <dependency>
        <groupId>com.github.iotaledger.iota-java</groupId>
        <artifactId>jota</artifactId>
        <classifier>jar-with-dependencies</classifier>
        <version>[VERSION_INFORMATION]</version>
    </dependency>
  3. Change the value of the <version> tag to either a release number or the first 10 characters of a Git commit hash: <version>b703ef3c05f05</version> or <version>1.0.0-beta9</version>

Note: Find the latest version on the Jitpack page.

Manual installation

  1. Clone or download the GitHub repository.

    Inside the project, you'll have the following directories:

    • jota
    • jota-parent
  2. Import and reference the jota directory in your project For example in Eclipse: right mouse on your project -> Properties -> Java Build Path -> Projects -> Add 'jota'

  3. In the jota directory, run the following command:

    mvn clean install

You'll have a .jar file called jota-[VERSION]-jar-with-dependencies.jar, depending on your version of the library.

Getting Started

After you've installed the library, you can connect to an IRI node to send transactions to it and interact with the Tangle. An extended guide can be found on our documentation portal, we strongly recommend you to go here for starting off. A quick start tutorial is shown below.

To connect to a local IRI node on port 14265, do the following:

IotaAPI api = new IotaAPI.Builder().build();
GetNodeInfoResponse response = api.getNodeInfo();

To connect to a remote IRI node on port 14265, do the following:

IotaAPI api = new IotaAPI.Builder()
        .protocol("http")
        .host("URL OF THE REMOTE IRI NODE")
        .port(14265)
        .build();
GetNodeInfoResponse response = api.getNodeInfo();

Note: To separate your IRI node configuration from the implementation, you can also specify your IRI node configuration in a Java .properties file or as command line flags. These options are useful if you develop an open-source app which is deployed on a CI and don't want contributors to see the internal IRI node configuration. To make the API read from this file, add the configuration to the builder like so: .config(new FileConfig("node_config.properties"))

Example .properties files

iota.node.protocol=http
iota.node.host=127.0.0.1
iota.node.port=14265

Most API calls are synchronous. Therefore, we recommend that you call the API from a background thread or a worker thread to stop the API from blocking other threads such as the UI or the main thread.

API Reference

For a full list of API commands for the IOTA Java client library, go to the GitHub page.

Here are some of the most commonly used API functions:

Examples

We have a list of test cases in the src/test/java directory that you can use as a reference when developing apps with IOTA. A good starter is the IotaAPITest case.

Here's how you could send a zero-value transaction, using the library. For the guide, see the documentation portal.

class SendData {
    public static void main(String[] args) throws ArgumentException {

        // Connect to a node
        IotaAPI api = new IotaAPI.Builder()
            .protocol("https")
            .host("nodes.devnet.thetangle.org")
            .port(443)
            .build();

        int depth = 3;
        int minimumWeightMagnitude = 9;

        // Even though a seed is not necessary because zero value transactions are not signed,
        // the library requires a seed to send a transaction.
        // This seed can be any random string of 81 trytes
        String myRandomSeed = SeedRandomGenerator.generateNewSeed();

        // Define any security level (like the seed, this is not used)
        int securityLevel = 2;

        // Define an address.
        // This does not need to belong to anyone or have IOTA tokens.
        // It must only contain a maximum of 81 trytes
        // or 90 trytes with a valid checksum
        String address = "ZLGVEQ9JUZZWCZXLWVNTHBDX9G9KZTJP9VEERIIFHY9SIQKYBVAHIMLHXPQVE9IXFDDXNHQINXJDRPFDXNYVAPLZAW";
        // This is a zero-value transaction
        int value = 0;
        // Define a message to send.
        // This message must include only ASCII characters.
        String message = TrytesConverter.asciiToTrytes("Hello world");
        String tag = "HELLOWORLD";

        Transfer zeroValueTransaction = new Transfer(address, value, message, tag);
        
        ArrayList<Transfer> transfers = new ArrayList<Transfer>();

        transfers.add(zeroValueTransaction);
        
        // Create a bundle from the transfers list
        // and send the transaction to the node
        try { 
            // Since we don't send any value, we can skip validation of inputs
            SendTransferResponse response = api.sendTransfer(myRandomSeed, securityLevel, depth, minimumWeightMagnitude, transfers, null, null, false, false, null);
            System.out.println(response.getTransactions());
        } catch (ArgumentException e) { 
            // Handle error
            e.printStackTrace(); 
         }
    }
}

Change logs

Supporting the project

If the IOTA Java client library has been useful to you and you feel like contributing, consider posting a bug report, feature request or a pull request.

We have some basic contribution guidelines to keep our code base stable and consistent.

Joining the discussion

If you want to get involved in the community, need help with getting setup, have any issues related with the library or just want to discuss blockchain, distributed ledgers, and IoT with other people, feel free to join our Discord.

More Repositories

1

legacy-wallet-use-trinity-wallet-instead

IOTA Wallet
JavaScript
2,076
star
2

iri

IOTA Reference Implementation
Java
1,158
star
3

iota.js

IOTA JavaScript
TypeScript
966
star
4

stronghold.rs

Stronghold is a secret management engine written in rust.
Rust
489
star
5

firefly

The official IOTA and Shimmer wallet
TypeScript
478
star
6

trinity-wallet

Trinity is IOTA's old, deprecated wallet. Use Firefly instead.
JavaScript
473
star
7

goshimmer

Prototype implementation of IOTA 2.0
Go
389
star
8

iota.go

IOTA Go API Library. Find documentation on https://wiki.iota.org/build/welcome
Go
356
star
9

iota.py

PyOTA: The IOTA Python API Library
Python
344
star
10

hornet

HORNET is a powerful IOTA fullnode software
Go
306
star
11

identity.rs

Implementation of the Decentralized Identity standards such as DID and Verifiable Credentials by W3C for the IOTA Tangle.
Rust
285
star
12

wasp

Node for IOTA Smart Contracts
Go
285
star
13

bee

A framework for IOTA nodes, clients and applications in Rust
Rust
277
star
14

iota.rs

Official IOTA Rust library.
Rust
229
star
15

streams

IOTA Streams, a framework for cryptographic protocols called Applications. Replaces Masked Authenticated Messaging (MAM). Alpha version.
Rust
217
star
16

wallet.rs

Build wallets and other applications involving IOTA value transfer.
Rust
159
star
17

entangled

enTangle'd is an amalgamation of all things Tangle
C
110
star
18

iota-wiki

IOTA Wiki
TypeScript
109
star
19

tips

Tangle Improvement Proposals for the IOTA technology stack.
JavaScript
86
star
20

android-wallet-app

IOTA Android Wallet Application
Java
82
star
21

iota.legacy.rs

IOTA implementation ( rust )
Rust
77
star
22

chronicle.rs

A framework for building IOTA permanodes
Rust
73
star
23

iota.c

IOTA client library in C
C
67
star
24

crypto.rs

The canonical source of cryptographic ground-truth for IOTA projects that use Rust.
Rust
66
star
25

MAM

Masked Authentication Messaging
Rust
65
star
26

iota.flash.js

JavaScript
64
star
27

iota.lib.csharp

Iota.Lib.Csharp
C#
62
star
28

IOTA-2.0-Research-Specifications

This is the repository of the IOTA 2.0 Research Specifications.
JavaScript
61
star
29

explorer

Explore the IOTA Tangle
TypeScript
60
star
30

hive.go

A Go library containing data structures, various utils and abstractions which are used by both GoShimmer and Hornet.
Go
60
star
31

one-click-tangle

"One Click Tangle" intends to make lives easier to IOTA adopters by providing pre-configured scripts and recipes that allow to deploy IOTA Networks and Nodes "in one click".
Shell
55
star
32

spark-wallet

A low-security wallet intended for short-term use and to send small amounts of IOTA tokens
Svelte
55
star
33

hub

C++
54
star
34

data-marketplace

Proof of Concept Data Marketplace built using MAM and IOTA Tangle.
JavaScript
54
star
35

documentation-platform

Legacy documentation platform
JavaScript
53
star
36

wiki-legacy

These docs have moved!
52
star
37

iota-sdk

The IOTA SDK provides developers with a seamless experience to develop on IOTA by providing account abstractions and clients to interact with node APIs.
Rust
50
star
38

kerl

IOTA is adding an additional hashing function, based on Keccak, with conversion to ternary. The following document describes the functionality and specification to be implemented.
Rust
50
star
39

industry-marketplace

The world's first autonomous and decentralized Industry Marketplace
JavaScript
49
star
40

node-dashboard

TypeScript
45
star
41

compass

Java
44
star
42

iota-core

Go
43
star
43

qupla

A QUbic Programming LAnguage
Java
43
star
44

meta-iota

OpenEmbedded layer for the IOTA Distributed Ledger
BitBake
42
star
45

cli-wallet

Rust
41
star
46

IOTA-2.0-DevNet-wallet

GUI Wallet for use with the IOTA 2.0 DevNet
TypeScript
39
star
47

curl.lib.js

IOTA Proof-of-Work algorithm ported to Javascript to work in WebGL2-enabled browsers
JavaScript
38
star
48

mam.js

Pure JavaScript implementation of MAMv0
TypeScript
37
star
49

poc-ipfs

Demonstration of combining IOTA with IPFS for data storage.
TypeScript
33
star
50

identity.ts

TypeScript
32
star
51

cli-app

CLI App that acts as a wallet
JavaScript
31
star
52

engineering-updates

Periodical updates from the Engineering teams
31
star
53

ccurl

C port of the Curl library
C
30
star
54

integration-services

TypeScript
30
star
55

wasplib

Go
29
star
56

ict

Java
29
star
57

TangleSim

Go
29
star
58

giotan

The CLI Tool for IOTA in Go
Go
28
star
59

chat.ixi

JavaScript
28
star
60

iota.crypto.js

JavaScript
28
star
61

vdf

Implementation of verifiable delay function.
Python
25
star
62

cliri

Coo Less IRI
Java
24
star
63

introduction-docs

Documentation Page for Chrysalis (IOTA 1.5) and Stardust (Shimmer)
JavaScript
24
star
64

docs

IOTA documentation website - PRs welcome!
JavaScript
24
star
65

ledger-iota-app

C
23
star
66

participation-events

22
star
67

HyperledgerFabric-IOTA-Connector

IOTA connector for Hyperledger Fabric Chaincode
Go
22
star
68

selv-mobile

Svelte
21
star
69

chrysalis-faucet

HTML
21
star
70

qubic

Java
20
star
71

iota-area-codes

IACs are a proposed standard for tagging IOTA transactions with a geo-location, which allows them to be fetched based on their location.
TypeScript
19
star
72

fpc-sim

Fast Probabilistic Consensus Simulator
Go
19
star
73

autopeering-sim

Autopeering Simulator
Go
19
star
74

tangle-utils-website

A web site full of utilities for all things tangle, transaction and IOTA.
TypeScript
18
star
75

iota-gui-beta

Beta of IOTA GUI client.
17
star
76

FirstPartyOracle

JavaScript
16
star
77

gh-tangle-release

GitHub Action to publish release details to the Tangle
JavaScript
16
star
78

ledger.rs

Rust
15
star
79

remote-signer

Rust
15
star
80

client-load-balancer

Perform client side load balancing across a list of nodes
TypeScript
15
star
81

bee-meeting-minutes

14
star
82

outdated-mam.client.js

DEPRECATED MAM js client
JavaScript
14
star
83

trade-poc

IOTA Supply Chain Proof-of-Concept
JavaScript
14
star
84

sandbox

Go
14
star
85

access-server

C
14
star
86

mam-explorer

JavaScript
13
star
87

ccurl.interface.js

cCurl Interface for NodeJS
JavaScript
13
star
88

channels-examples

Sample code for IOTA Channels
Rust
13
star
89

bee-rfcs

RFCs to changes to Bee
Shell
13
star
90

inx-chronicle

IOTA permanode implemented using the IOTA Node Extension (INX) interface.
Rust
13
star
91

chronicle

C
13
star
92

esp32-client-sdk

IOTA Client Software Development Kit(SDK) for ESP32
C
13
star
93

seed-migration-tool

IOTA Seed Migration Tool
HTML
12
star
94

iota-css-theme

SCSS
12
star
95

discord-invite-captcha

Simple webserver that will grant you a one-time-use invite for a Discord server if you solve the Captcha.
HTML
12
star
96

drng

Go
12
star
97

tangle.js

Libraries and utilities that make it easier to build applications on the Tangle
TypeScript
12
star
98

streams-examples

Rust
11
star
99

mam.c

C
11
star
100

iota-identity-tutorial

TypeScript
11
star