io.bytom:bytom-sdk-java

The Official Java SDK for Bytom Core Developer Edition

License

License

Categories

Categories

Java Languages
GroupId

GroupId

io.bytom
ArtifactId

ArtifactId

bytom-sdk-java
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

io.bytom:bytom-sdk-java
The Official Java SDK for Bytom Core Developer Edition
Project URL

Project URL

https://github.com/bytom/
Source Code Management

Source Code Management

https://github.com/chainworld/java-bytom.git

Download bytom-sdk-java

How to add to project

<!-- https://jarcasting.com/artifacts/io.bytom/bytom-sdk-java/ -->
<dependency>
    <groupId>io.bytom</groupId>
    <artifactId>bytom-sdk-java</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/io.bytom/bytom-sdk-java/
implementation 'io.bytom:bytom-sdk-java:1.0.2'
// https://jarcasting.com/artifacts/io.bytom/bytom-sdk-java/
implementation ("io.bytom:bytom-sdk-java:1.0.2")
'io.bytom:bytom-sdk-java:jar:1.0.2'
<dependency org="io.bytom" name="bytom-sdk-java" rev="1.0.2">
  <artifact name="bytom-sdk-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.bytom', module='bytom-sdk-java', version='1.0.2')
)
libraryDependencies += "io.bytom" % "bytom-sdk-java" % "1.0.2"
[io.bytom/bytom-sdk-java "1.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
commons-httpclient : commons-httpclient jar 3.1
log4j : log4j jar 1.2.17
com.google.code.gson : gson jar 2.8.0
org.apache.commons : commons-lang3 jar 3.7

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Bytom Java SDK

This SDK contains methods for easily interacting with the Bytom API. Below are examples to get you started. For more information, please see Bytom API reference documentation at https://github.com/Bytom/bytom/wiki

Latest Version Total Downloads

Table of Contents

Installation

There are various ways to install and use this sdk. We'll elaborate on a couple here. Note that the Bytom JAVA SDK requires JAVA 7 or newer.

Maven

<dependency>
  <groupId>io.bytom</groupId>
  <artifactId>bytom-sdk-java</artifactId>
  <version>1.0.2</version>
</dependency>

Building from source code

To clone, compile, and install in your local maven repository (or copy the artifacts from the target/ directory to wherever you need them):

git clone [email protected]:chainworld/java-bytom.git
cd java-bytom
mvn install

5-Minute Guide

This guide will walk you through the basic functions of Bytom:

Initialize the SDK

Create an instance of the SDK. By default, the SDK will try to access a core located at http://127.0.0.1:9888, which is the default if you’re running Bytom Wallet locally.

public static Client generateClient() throws BytomException {
	String coreURL = Configuration.getValue("bytom.api.url");
	String accessToken = Configuration.getValue("client.access.token");
	if (coreURL == null || coreURL.isEmpty()) {
		coreURL = "http://127.0.0.1:9888/";
	}
	return new Client(coreURL, accessToken);
}

Create Keys

Key key = Key.create(client, "alias", "password");

It will create a key whose alias is 'alias' while password is 'password'.

Create an Asset

Create a new asset, providing an alias, key, and quorum.

String asset = "GOLD";
Asset testAsset = new Asset.Builder()
		      .setAlias(asset)
		      .addRootXpub(key.xpub)
		      .setQuorum(1)
		      .create(client);

Create an Account

Create an account, providing an alias, key, and quorum.

Account account = new Account.Builder()
		      .setAlias("alice")
		      .addXpub(key.xpub)
		      .setQuorum(1)
		      .create(client);

Create an Account Address

new Account.ReceiverBuilder()
   .setAccountId(account.id)
   .create(client);

Build the Transaction

Transaction.Template controlAddressTx = new Transaction.Builder()
			.addAction(new Transaction.Action.SpendFromAccount()
					.setAccountId(account.id)
					.setAssetId(asset.id)
					.setAmount(300000000))
			.addAction(new Transaction.Action.ControlWithAddress()
					.setAddress(address.id)
					.setAssetId(asset.id)
					.setAmount(200000000))
					.build(client);

Sign the Transaction

Transaction.Template singerTx = new Transaction.SignerBuilder()
                                   .sign(client,controlAddressTx, "password");

Submit the Transaction

Transaction.submit(client, singerTx); 

All usage examples

You find more detailed documentation at /doc. Also you can find Test Cases at Junit Test Cases

Support and Feedback

If you find a bug, please submit the issue in Github directly. Bytom-JAVA-SDK Issues

License

Bytom JAVA SDK is based on the MIT protocol.

http://www.opensource.org/licenses/MIT

Versions

Version
1.0.2
1.0.1