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 approach.
9 public static Client generateClient() throws BytomException {
10 String coreURL = Configuration.getValue("bytom.api.url");
11 String accessToken = Configuration.getValue("client.access.token");
12 if (coreURL == null || coreURL.isEmpty()) {
13 coreURL = "http://127.0.0.1:9888/";
15 return new Client(coreURL, accessToken);
18 Client client = TestUtils.generateClient();
23 * [`Step 1: Create a key`](#create-a-key)
24 * [`Step 2: Create an account`](#create-an-account)
25 * [`Step 3: Create an receiver`](#create-an-receiver)
26 * [`Step 4: Create an asset`](#create-an-asset)
27 * [`Step 5: Issue asset`](#issue-asset)
28 * [`Firstly build the transaction`](#firstly-build-the-transaction)
29 * [`Secondly sign the transaction`](#secondly-sign-the-transaction)
30 * [`Finally submit the transaction`](#finally-submit-the-transaction)
32 > For more details, see ![API methods](https://github.com/Bytom/java-sdk/blob/master/doc/index.md#api-methods)
37 String alias = "test";
38 String password = "123456";
40 Key.Builder builder = new Key.Builder().setAlias(alias).setPassword(password);
41 Key key = Key.create(client, builder);
47 String alias = "sender-account";
49 List<String> root_xpubs = new ArrayList<String>();
50 root_xpubs.add(senderKey.xpub);
52 Account.Builder builder = new Account.Builder().setAlias(alias).setQuorum(quorum).setRootXpub(root_xpubs);
54 Account account = Account.create(client, builder);
60 String alias = receiverAccount.alias;
61 String id = receiverAccount.id;
63 Account.ReceiverBuilder receiverBuilder = new Account.ReceiverBuilder().setAccountAlias(alias).setAccountId(id);
64 Receiver receiver = receiverBuilder.create(client);
70 String alias = "receiver-asset";
72 List<String> xpubs = receiverAccount.xpubs;
74 Asset.Builder builder = new Asset.Builder()
78 receiverAsset = builder.create(client);
83 ### Firstly build the transaction
86 Transaction.Template controlAddress = new Transaction.Builder()
88 new Transaction.Action.SpendFromAccount()
89 .setAccountId(senderAccount.id)
90 .setAssetId(senderAsset.id)
94 new Transaction.Action.ControlWithAddress()
95 .setAddress(receiverAddress.address)
96 .setAssetId(senderAsset.id)
101 ### Secondly sign the transaction
104 Transaction.Template singer = new Transaction.SignerBuilder().sign(client,
105 controlAddress, "123456");
108 ### Finally submit the transaction
111 Transaction.SubmitResponse txs = Transaction.submit(client, singer);