-
io.emeraldpay.polkaj:polkaj-scale:0.3.0
- SCALE codec implementation -
io.emeraldpay.polkaj:polkaj-scale-types:0.3.0
- SCALE mapping for standard Polkadot types -
io.emeraldpay.polkaj:polkaj-schnorrkel:0.3.0
- Schnorrkel for Java -
io.emeraldpay.polkaj:polkaj-ss58:0.3.0
- SS58 codec to encode/decode addresses and pubkeys -
io.emeraldpay.polkaj:polkaj-common-types:0.3.0
- common types (Address, DotAmount, Hash256, etc) -
io.emeraldpay.polkaj:polkaj-json-types:0.3.0
- JSON RPC mapping to Java classes -
io.emeraldpay.polkaj:polkaj-api-base:0.3.0
- RPC base classes -
io.emeraldpay.polkaj:polkaj-api-http:0.3.0
- JSON RPC HTTP client -
io.emeraldpay.polkaj:polkaj-api-ws:0.3.0
- JSON RPC WebSocket client -
io.emeraldpay.polkaj:polkaj-tx:0.3.0
- Storage access and Extrinsics
To use development SNAPSHOT versions you need to install the library into the local Maven repository.
gradle install
repositories {
// polkaj public repo
maven { url "https://dl.bintray.com/emerald/polkaj" }
// required for com.github.multiformats:java-multibase library
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'io.emeraldpay.polkaj:polkaj-api-http:0.3.0'
}
See Documentation in ./docs
directory, and a demonstration in ./examples
.
PolkadotHttpApi client = PolkadotApi.newBuilder()
.rpcCallAdapter(JavaHttpAdapter.newBuilder().build())
.build();
Future<Hash256> hashFuture = client.execute(
PolkadotApi.commands().getFinalizedHead()
);
Hash256 hash = hashFuture.get();
System.out.println("Current head: " + hash);
Future<BlockResponseJson> blockFuture = client.execute(
PolkadotApi.commands().getBlock(hash)
);
BlockResponseJson block = blockFuture.get();
System.out.println("Current height: " + block.getBlock().getHeader().getNumber());
System.out.println("State hash: " + block.getBlock().getHeader().getStateRoot());
client.close();