3 This page will document the API classes and ways to properly use the API.
4 Subsequent new releases also maintain backward compatibility with this class
5 approach. For more information, please see Bytom API reference documentation
6 at [Bytom wiki](https://github.com/Bytom/bytom/wiki/API-Reference)
10 ### Building from source code
12 To clone, compile, and install in your local maven repository (or copy the artifacts from the target/ directory to wherever you need them):
15 git clone https://github.com/Bytom/bytom-java-sdk.git
17 mvn package -Dmaven.test.skip=true
24 public static Client generateClient() throws BytomException {
25 String coreURL = Configuration.getValue("bytom.api.url");
26 String accessToken = Configuration.getValue("client.access.token");
27 if (coreURL == null || coreURL.isEmpty()) {
28 coreURL = "http://127.0.0.1:9888/";
30 return new Client(coreURL, accessToken);
33 Client client = Client.generateClient();
35 > Note: you can touch a file named ```config.properties``` in resources folder to config ```bytom.api.url``` and ```client.access.token``` by custom.
39 * [`Step 1: Create a key`](#create-a-key)
40 * [`Step 2: Create an account`](#create-an-account)
41 * [`Step 3: Create an receiver`](#create-an-receiver)
42 * [`Step 4: Create an asset`](#create-an-asset)
43 * [`Step 5: Issue asset`](#issue-asset)
44 * [`Firstly build the transaction`](#firstly-build-the-transaction)
45 * [`Secondly sign the transaction`](#secondly-sign-the-transaction)
46 * [`Finally submit the transaction`](#finally-submit-the-transaction)
48 > For more details, see [API methods](https://github.com/Bytom/bytom-java-sdk/blob/master/java-sdk/doc/index.md#api-methods)
53 String alias = "test";
54 String password = "123456";
56 Key.Builder builder = new Key.Builder().setAlias(alias).setPassword(password);
57 Key key = Key.create(client, builder);
63 String alias = "sender-account";
65 List<String> root_xpubs = new ArrayList<String>();
66 root_xpubs.add(senderKey.xpub);
68 Account.Builder builder = new Account.Builder().setAlias(alias).setQuorum(quorum).setRootXpub(root_xpubs);
70 Account account = Account.create(client, builder);
73 ### Create an receiver
76 String alias = receiverAccount.alias;
77 String id = receiverAccount.id;
79 Account.ReceiverBuilder receiverBuilder = new Account.ReceiverBuilder().setAccountAlias(alias).setAccountId(id);
80 Receiver receiver = receiverBuilder.create(client);
86 String alias = "receiver-asset";
88 List<String> xpubs = receiverAccount.xpubs;
90 Asset.Builder builder = new Asset.Builder()
94 receiverAsset = builder.create(client);
99 For more transaction details, see [transactions](https://github.com/Bytom/bytom-java-sdk/blob/master/java-sdk/doc/transactions.md)
101 #### Firstly build the transaction
104 Transaction.Template controlAddress = new Transaction.Builder()
106 new Transaction.Action.SpendFromAccount()
107 .setAccountId(senderAccount.id)
108 .setAssetId(senderAsset.id)
109 .setAmount(300000000)
112 new Transaction.Action.ControlWithAddress()
113 .setAddress(receiverAddress.address)
114 .setAssetId(senderAsset.id)
115 .setAmount(200000000)
119 #### Secondly sign the transaction
122 Transaction.Template singer = new Transaction.SignerBuilder().sign(client,
123 controlAddress, "123456");
126 #### Finally submit the transaction
129 Transaction.SubmitResponse txs = Transaction.submit(client, singer);
133 ### All usage examples
135 For more details you can see [doc](https://github.com/Bytom/bytom-java-sdk/blob/master/doc/index.md#api-methods). And you can find Test Cases at [Junit Test Cases](https://github.com/Bytom/bytom-java-sdk/tree/master/src/test/java/io/bytom/integration)
137 ## Support and Feedback
139 If you find a bug, please submit the issue in Github directly by using [Issues](https://github.com/Bytom/bytom-java-sdk/issues)
143 Bytom JAVA SDK is based on the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) protocol.