All Projects → radixdlt → radixdlt-java

radixdlt / radixdlt-java

Licence: MIT license
A Java/Android Client library for interacting with a RADIX Distributed Ledger.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

Projects that are alternatives of or similar to radixdlt-java

Composer
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 1,676 (+2105.26%)
Mutual labels:  distributed-ledger
composer-sample-models
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 30 (-60.53%)
Mutual labels:  distributed-ledger
blockchain-multichain
Application for proposals using blockchain with MultiChain.
Stars: ✭ 18 (-76.32%)
Mutual labels:  distributed-ledger
Fabric
Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.
Stars: ✭ 12,911 (+16888.16%)
Mutual labels:  distributed-ledger
Composer Sample Networks
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 226 (+197.37%)
Mutual labels:  distributed-ledger
cocol
Rapid blockchain prototyping
Stars: ✭ 19 (-75%)
Mutual labels:  distributed-ledger
Fabric Gateway Java
Hyperledger Fabric Gateway SDK for Java https://wiki.hyperledger.org/display/fabric
Stars: ✭ 122 (+60.53%)
Mutual labels:  distributed-ledger
flowchain-ledger
A distributed ledger for the p2p and decentralized IoT devices in JavaScript.
Stars: ✭ 58 (-23.68%)
Mutual labels:  distributed-ledger
unit-e
A digital currency for a new era of decentralized trust
Stars: ✭ 45 (-40.79%)
Mutual labels:  distributed-ledger
composer-atom-plugin
⚠️ ⚠️ ⚠️ Hyperledger Composer has been deprecated ⚠️ ⚠️ ⚠️
Stars: ✭ 14 (-81.58%)
Mutual labels:  distributed-ledger
Py Ipv8
Python implementation of the IPv8 layer
Stars: ✭ 157 (+106.58%)
Mutual labels:  distributed-ledger
Iroha
Iroha - A simple, enterprise-grade decentralized ledger
Stars: ✭ 210 (+176.32%)
Mutual labels:  distributed-ledger
meta-iota
OpenEmbedded layer for the IOTA Distributed Ledger
Stars: ✭ 41 (-46.05%)
Mutual labels:  distributed-ledger
Advanced Eos Examples
EOS Smart Contract Development Examples
Stars: ✭ 146 (+92.11%)
Mutual labels:  distributed-ledger
fabric-cop
This is a read-only mirror of https://gerrit.hyperledger.org/r/#/admin/projects/fabric-cop no pull requests accepted
Stars: ✭ 13 (-82.89%)
Mutual labels:  distributed-ledger
Documentation
Ontology Documents https://ont.io
Stars: ✭ 122 (+60.53%)
Mutual labels:  distributed-ledger
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.
Stars: ✭ 20 (-73.68%)
Mutual labels:  distributed-ledger
sawtooth-docs
Documentation source for Sawtooth Lake. Published docs at the link.
Stars: ✭ 10 (-86.84%)
Mutual labels:  distributed-ledger
distributed-compliance-ledger
DCL is a public permissioned ledger framework for Zigbee compliance certification of device models. The ledger is based on Cosmos SDK and Tendermint.
Stars: ✭ 41 (-46.05%)
Mutual labels:  distributed-ledger
fabric-token-sdk
The Fabric Token SDK is a set of API and services that lets developers create token-based distributed application on Hyperledger Fabric.
Stars: ✭ 63 (-17.11%)
Mutual labels:  distributed-ledger

IMPORTANT

This repository has been archived as part of our move to a monorepo.

  • Monorepo is here
  • The code for this repo is available in the radixdlt-java subdirectory of the monorepo.

radixdlt-java

Build Status Quality Gate Reliability Security Code Corevage

radixdlt-java is a Java/Android Client library for interacting with a Radix Distributed Ledger.

Table of contents

Features

  • Connection to the Betanet test network
  • Fee-less transactions for testnets
  • Public Key Identity Creation
  • Token Creation (ERC-777 style)
  • Message sending
  • RXJava 2 based
  • Utilizes JSON-RPC over Websockets

Installation

Include the following gradle dependency:

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.radixdlt:radixdlt-java:1.0-beta.19'
}

Getting Started

Identities

An Identity is the user's credentials (or more technically the manager of the public/private key pair) into the ledger, allowing a user to own tokens and send tokens as well as decrypt data.

To create/load an identity from a file:

RadixIdentity identity = RadixIdentities.loadOrCreateEncryptedFile("filename.key", "password123");

This will either create or load a file with a public/private key and encrypted with the given password.

Universes

A Universe is an instance of a Radix Distributed Ledger which is defined by a genesis atom and a dynamic set of unpermissioned nodes forming a network.

A predefined configuration to bootstrap into the betanet network is available:

BootstrapConfig config = Bootstrap.BETANET;

Radix Application API

The Radix Application API is a client side API exposing high level abstractions to make DAPP creation easier.

To initialize the API:

RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.BETANET, identity);

To continually sync and pull from the network ledger on your account:

Disposable d = api.pull();

To stop syncing:

d.dispose();

Addresses

An address is a reference to an account and allows a user to receive tokens and/or data from other users.

You can get your own address by:

RadixAddress myAddress = api.getAddress();

Or from a base58 string:

RadixAddress anotherAddress = RadixAddress.fromString("JHB89drvftPj6zVCNjnaijURk8D8AMFw4mVja19aoBGmRXWchnJ");

Code Examples

Sending Messages

Immutable data can be stored on the ledger. The data can be encrypted so that only selected identities can read the data.

To send the encrypted string Hello which only the sender and recipient can read:

Result result = api.sendMessage(<to-address>, "Hello".getBytes(StandardCharsets.UTF_8), true);
result.blockUntilComplete();

To send the unencrypted string Hello:

Result result = api.sendMessage(<to-address>, "Hello".getBytes(StandardCharsets.UTF_8), false);
result.blockUntilComplete();

Or equivalently,

SendMessageAction msgAction = SendMessageAction.create(api.getAddress(), <to-address>, "Hello".getBytes(StandardCharset.UTF_8), false);
Result result = api.execute(msgAction);
result.blockUntilComplete();

Receiving Messages

To then read (and decrypt if necessary) all the readable data sent to you:

Observable<DecryptedMessage> readable = api.observeMessages();
readable.subscribe(data -> { ... });

Creating Tokens

To create a token, an RRI or radix resource identifier must first be constructed:

RRI tokenRRI = RRI.of(api.getAddress(), "NEW");

To create a fixed-supply token:

Result result = api.createFixedSupplyToken(tokenRRI, "New Token", "The Best Token", BigDecimal.valueOf(1000.0));
result.blockUntilComplete();

To create a multi-issuance token:

Result result = api.createMultiIssuance(tokenRRI, "New Token", "The Best Token");
result.blockUntilComplete();

Or equivalently,

CreateTokenAction createAction = CreateTokenAction.create(
  tokenRRI,
  "New Token",
  "The Best Token",
  BigDecimal.ZERO,
  TokenUnitConversions.getMinimumGranularity(),
  TokenSupplyType.MUTABLE
); 
Result result = api.execute(createAction);
result.blockUntilComplete();

Minting Tokens

To mint 1000 tokens (must be multi-issuance) in your account:

Result result = api.mintTokens(tokenRRI, BigDecimal.valueOf(1000.0));
result.blockUntilComplete();

Or equivalently,

MintTokensAction mintAction = MintTokensAction.create(tokenRRI, api.getAddress(), BigDecimal.valueOf(1000.0));
Result result = api.execute(mintAction);
result.blockUntilComplete();

Burning Tokens

To burn 1000 tokens (must be multi-issuance) in your account:

Result result = api.burnTokens(tokenRRI, BigDecimal.valueOf(1000.0));
result.blockUntilComplete();

Or equivalently,

BurnTokensAction burnAction = BurnTokensAction.create(tokenRRI, api.getAddress(), BigDecimal.valueOf(1000.0));
Result result = api.execute(burnAction);
result.blockUntilComplete();

Sending Tokens

To send an amount from my address to another address:

Result result = api.sendTokens(tokenRRI, BigDecimal.valueOf(10.99), <to-address>);
result.blockUntilComplete();

Or equivalently,

TransferTokensAction sendAction = TransferTokensAction.create(
  tokenRRI,
  api.getAddress(),
  <to-address>,
  BigDecimal.valueOf(10.00),
  null
);
Result result = api.execute(sendAction);
result.blockUntilComplete();

Retrieving Tokens

To retrieve all of the token transfers which have occurred in my account:

Observable<TokenTransfer> transfers = api.observeTokenTransfers();
transfers.subscribe(tx -> { ... });

To get a stream of the balance of tokens in my account:

Observable<BigDecimal> balance = api.observeBalance(tokenRRI);
balance.subscribe(bal -> { ... });

Executing Atomic Transactions

To execute an atomic transaction of creating a token, minting, then sending:

CreateTokensAction createAction = CreateTokenAction.create(
  tokenRRI,
  "Joshy Token",
  "The Best Coin Ever",
  BigDecimal.ZERO,
  TokenUnitConversions.getMinimumGranularity(),
  TokenSupplyType.MUTABLE
);
MintTokensAction mintAction = MintTokensAction.create(
  tokenRRI,
  api.getAddress(),
  BigDecimal.valueOf(1000000.0)
);
TransferTokensAction transferAction =  TransferTokensAction.create(
  tokenRRI,
  api.getAddress(),
  <to-address>,
  BigDecimal.valueOf(1000000.0),
  null
);

Transaction tx = api.createTransaction();
tx.stage(createAction);
tx.stage(mintAction);
tx.stage(transferAction);
Result result = tx.commitAndPush();
result.blockUntilComplete();

Contribute

Contributions are welcome, we simply ask to:

  • Fork the codebase
  • Make changes
  • Submit a pull request for review

When contributing to this repository, we recommend discussing with the development team the change you wish to make using a GitHub issue before making changes.

Please follow our Code of Conduct in all your interactions with the project.

Links

Link Description
radixdlt.com Radix DLT Homepage
documentation Radix Knowledge Base
forum Radix Technical Forum
@radixdlt Follow Radix DLT on Twitter

License

The radixdlt-java library is released under the MIT License.

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