MCPcopy Index your code
hub / github.com/chain/Core / main

Method main

docs/core/examples/java/FiveMinuteGuide.java:6–85  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

4
5class FiveMinuteGuide {
6 public static void main(String[] args) throws Exception {
7 // snippet create-client
8 Client client = new Client();
9 // endsnippet
10
11 // snippet create-key
12 MockHsm.Key key = MockHsm.Key.create(client);
13 // endsnippet
14
15 // snippet signer-add-key
16 HsmSigner.addKey(key, MockHsm.getSignerClient(client));
17 // endsnippet
18
19 // snippet create-asset
20 new Asset.Builder()
21 .setAlias("gold")
22 .addRootXpub(key.xpub)
23 .setQuorum(1)
24 .create(client);
25 // endsnippet
26
27 // snippet create-account-alice
28 new Account.Builder()
29 .setAlias("alice")
30 .addRootXpub(key.xpub)
31 .setQuorum(1)
32 .create(client);
33 // endsnippet
34
35 // snippet create-account-bob
36 new Account.Builder()
37 .setAlias("bob")
38 .addRootXpub(key.xpub)
39 .setQuorum(1)
40 .create(client);
41 // endsnippet
42
43 // snippet issue
44 Transaction.Template issuance = new Transaction.Builder()
45 .addAction(new Transaction.Action.Issue()
46 .setAssetAlias("gold")
47 .setAmount(100)
48 ).addAction(new Transaction.Action.ControlWithAccount()
49 .setAccountAlias("alice")
50 .setAssetAlias("gold")
51 .setAmount(100)
52 ).build(client);
53
54 Transaction.submit(client, HsmSigner.sign(issuance));
55 // endsnippet
56
57 // snippet spend
58 Transaction.Template spending = new Transaction.Builder()
59 .addAction(new Transaction.Action.SpendFromAccount()
60 .setAccountAlias("alice")
61 .setAssetAlias("gold")
62 .setAmount(10))
63 .addAction(new Transaction.Action.ControlWithAccount()

Callers

nothing calls this directly

Calls 13

addKeyMethod · 0.95
getSignerClientMethod · 0.95
submitMethod · 0.95
signMethod · 0.95
addActionMethod · 0.80
createMethod · 0.65
setQuorumMethod · 0.45
addRootXpubMethod · 0.45
setAliasMethod · 0.45
buildMethod · 0.45
setAmountMethod · 0.45
setAssetAliasMethod · 0.45

Tested by

no test coverage detected