MCPcopy Create free account
hub / github.com/chain/Core / main

Method main

docs/core/examples/java/Accounts.java:8–189  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

6
7class Accounts {
8 public static void main(String[] args) throws Exception {
9 Client client = new Client();
10
11 MockHsm.Key assetKey = MockHsm.Key.create(client);
12 HsmSigner.addKey(assetKey, MockHsm.getSignerClient(client));
13
14 MockHsm.Key aliceKey = MockHsm.Key.create(client);
15 HsmSigner.addKey(aliceKey, MockHsm.getSignerClient(client));
16
17 MockHsm.Key bobKey = MockHsm.Key.create(client);
18 HsmSigner.addKey(bobKey, MockHsm.getSignerClient(client));
19
20 new Asset.Builder()
21 .setAlias("gold")
22 .addRootXpub(assetKey.xpub)
23 .setQuorum(1)
24 .create(client);
25
26 new Asset.Builder()
27 .setAlias("silver")
28 .addRootXpub(assetKey.xpub)
29 .setQuorum(1)
30 .create(client);
31
32 // snippet create-account-alice
33 new Account.Builder()
34 .setAlias("alice")
35 .addRootXpub(aliceKey.xpub)
36 .setQuorum(1)
37 .addTag("type", "checking")
38 .addTag("first_name", "Alice")
39 .addTag("last_name", "Jones")
40 .addTag("user_id", "12345")
41 .create(client);
42 // endsnippet
43
44 // snippet create-account-bob
45 new Account.Builder()
46 .setAlias("bob")
47 .addRootXpub(bobKey.xpub)
48 .setQuorum(1)
49 .addTag("type", "savings")
50 .addTag("first_name", "Bob")
51 .addTag("last_name", "Smith")
52 .addTag("user_id", "67890")
53 .create(client);
54 // endsnippet
55
56 // snippet list-accounts-by-tag
57 Account.Items accounts = new Account.QueryBuilder()
58 .setFilter("tags.type=$1")
59 .addFilterParameter("savings")
60 .execute(client);
61
62 while (accounts.hasNext()) {
63 Account a = accounts.next();
64 System.out.println("Account ID " + a.id + ", alias " + a.alias);
65 }

Callers

nothing calls this directly

Calls 15

addKeyMethod · 0.95
getSignerClientMethod · 0.95
submitMethod · 0.95
signMethod · 0.95
toJsonMethod · 0.95
fromJsonMethod · 0.95
addFilterParameterMethod · 0.80
setFilterMethod · 0.80
hasNextMethod · 0.80
addActionMethod · 0.80
setReceiverMethod · 0.80
createMethod · 0.65

Tested by

no test coverage detected