radixdlt-java is a Java/Android Client library for interacting with a Radix Distributed Ledger.
- Connection to the Alphanet test network
- Fee-less transactions for testnets
- Identity Creation
- Native token transfers
- Immutable data storage
- Instant Messaging and TEST token wallet Dapp implementation
- RXJava 2 based
- Utilizes JSON-RPC over Websockets
Include the following gradle dependency:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.radixdlt:radixdlt-java:0.11.9'
}
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", "password");
This will either create or load a file with a public/private key and encrypted with the given password.
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.
To bootstrap to the Alphanet test network:
RadixUniverse.bootstrap(Bootstrap.ALPHANET);
Note: No network connections will be made yet until it is required.
The Radix Application API is a client side API exposing high level abstractions to make DAPP creation easier.
To initialize the API:
RadixUniverse.bootstrap(Bootstrap.ALPHANET); // This must be called before RadixApplicationAPI.create()
RadixApplicationAPI api = RadixApplicationAPI.create(identity);
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.getMyAddress();
Or from a base58 string:
RadixAddress anotherAddress = RadixAddress.fromString("JHB89drvftPj6zVCNjnaijURk8D8AMFw4mVja19aoBGmRXWchnJ");
Immutable data can be stored on the ledger. The data can be encrypted so that only selected identities can read the data.
To store the encrypted string Hello
which only the user can read:
ECPublicKey myPublicKey = api.getMyPublicKey();
Data data = new DataBuilder()
.bytes("Hello".getBytes(StandardCharsets.UTF_8))
.addReader(myPublicKey)
.build();
Result result = api.storeData(data, <address>);
To store the unencrypted string Hello
:
Data data = new DataBuilder()
.bytes("Hello".getBytes(StandardCharsets.UTF_8))
.unencrypted()
.build();
Result result = api.storeData(data, <address>);
The returned Result
object exposes RXJava interfaces from which you can get
notified of the status of the storage action:
result.toCompletable().subscribe(<on-success>, <on-error>);
To then read (and decrypt if necessary) all the readable data at an address:
Observable<UnencryptedData> readable = api.getReadableData(<address>);
readable.subscribe(data -> { ... });
Note: data which is not decryptable by the user's key is simply ignored
To send an amount of TEST (the testnet native token) from my account to another address:
Result result = api.sendTokens(<to-address>, Amount.of(10, Asset.TEST));
To retrieve all of the token transfers which have occurred in my account:
Observable<TokenTransfer> transfers = api.getMyTokenTransfers(Asset.TEST);
transfers.subscribe(tx -> { ... });
To get a stream of the balance of TEST tokens in my account:
Observable<Amount> balance = api.getMyBalance(Asset.TEST);
balance.subscribe(bal -> { ... });
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.
Link | Description |
---|---|
radixdlt.com | Radix DLT Homepage |
documentation | Radix Knowledge Base |
forum | Radix Technical Forum |
@radixdlt | Follow Radix DLT on Twitter |
radixdlt-java is released under the MIT License.