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)
11 public static Client generateClient() throws BytomException {
12 String coreURL = Configuration.getValue("bytom.api.url");
13 String accessToken = Configuration.getValue("client.access.token");
14 if (coreURL == null || coreURL.isEmpty()) {
15 coreURL = "http://127.0.0.1:9888/";
17 return new Client(coreURL, accessToken);
20 Client client = TestUtils.generateClient();
25 * [`Step 1: Create a key`](#create-a-key)
26 * [`Step 2: Create an account`](#create-an-account)
27 * [`Step 3: Create an receiver`](#create-an-receiver)
28 * [`Step 4: Create an asset`](#create-an-asset)
29 * [`Step 5: Issue asset`](#issue-asset)
30 * [`Firstly build the transaction`](#firstly-build-the-transaction)
31 * [`Secondly sign the transaction`](#secondly-sign-the-transaction)
32 * [`Finally submit the transaction`](#finally-submit-the-transaction)
34 > For more details, see [API methods](https://github.com/Bytom/java-sdk/blob/master/doc/index.md#api-methods)
39 String alias = "test";
40 String password = "123456";
42 Key.Builder builder = new Key.Builder().setAlias(alias).setPassword(password);
43 Key key = Key.create(client, builder);
49 String alias = "sender-account";
51 List<String> root_xpubs = new ArrayList<String>();
52 root_xpubs.add(senderKey.xpub);
54 Account.Builder builder = new Account.Builder().setAlias(alias).setQuorum(quorum).setRootXpub(root_xpubs);
56 Account account = Account.create(client, builder);
62 String alias = receiverAccount.alias;
63 String id = receiverAccount.id;
65 Account.ReceiverBuilder receiverBuilder = new Account.ReceiverBuilder().setAccountAlias(alias).setAccountId(id);
66 Receiver receiver = receiverBuilder.create(client);
72 String alias = "receiver-asset";
74 List<String> xpubs = receiverAccount.xpubs;
76 Asset.Builder builder = new Asset.Builder()
80 receiverAsset = builder.create(client);
85 For more transaction details, see [transactions](https://github.com/Bytom/java-sdk/blob/master/doc/transactions.md)
87 ### Firstly build the transaction
90 Transaction.Template controlAddress = new Transaction.Builder()
92 new Transaction.Action.SpendFromAccount()
93 .setAccountId(senderAccount.id)
94 .setAssetId(senderAsset.id)
98 new Transaction.Action.ControlWithAddress()
99 .setAddress(receiverAddress.address)
100 .setAssetId(senderAsset.id)
101 .setAmount(200000000)
105 ### Secondly sign the transaction
108 Transaction.Template singer = new Transaction.SignerBuilder().sign(client,
109 controlAddress, "123456");
112 ### Finally submit the transaction
115 Transaction.SubmitResponse txs = Transaction.submit(client, singer);
118 > For more details, see [API methods](https://github.com/Bytom/java-sdk/blob/master/doc/index.md#api-methods)