(String[] args)
| 11 | |
| 12 | public class Quickstart { |
| 13 | public static void main(String[] args) throws Exception { |
| 14 | Client client = new Client(new URL(System.getenv("CHAIN_API_URL"))); |
| 15 | MockHsm.Key mainKey = MockHsm.Key.create(client); |
| 16 | HsmSigner.addKey(mainKey, MockHsm.getSignerClient(client)); |
| 17 | |
| 18 | new Account.Builder().setAlias("alice").addRootXpub(mainKey.xpub).setQuorum(1).create(client); |
| 19 | |
| 20 | new Account.Builder().setAlias("bob").addRootXpub(mainKey.xpub).setQuorum(1).create(client); |
| 21 | |
| 22 | new Asset.Builder().setAlias("gold").addRootXpub(mainKey.xpub).setQuorum(1).create(client); |
| 23 | |
| 24 | Transaction.Template issuance = |
| 25 | new Transaction.Builder() |
| 26 | .addAction(new Transaction.Action.Issue().setAssetAlias("gold").setAmount(100)) |
| 27 | .addAction( |
| 28 | new Transaction.Action.ControlWithAccount() |
| 29 | .setAccountAlias("alice") |
| 30 | .setAssetAlias("gold") |
| 31 | .setAmount(100)) |
| 32 | .build(client); |
| 33 | Transaction.submit(client, HsmSigner.sign(issuance)); |
| 34 | |
| 35 | Transaction.Template spending = |
| 36 | new Transaction.Builder() |
| 37 | .addAction( |
| 38 | new Transaction.Action.SpendFromAccount() |
| 39 | .setAccountAlias("alice") |
| 40 | .setAssetAlias("gold") |
| 41 | .setAmount(10)) |
| 42 | .addAction( |
| 43 | new Transaction.Action.ControlWithAccount() |
| 44 | .setAccountAlias("bob") |
| 45 | .setAssetAlias("gold") |
| 46 | .setAmount(10)) |
| 47 | .build(client); |
| 48 | Transaction.submit(client, HsmSigner.sign(spending)); |
| 49 | |
| 50 | Transaction.Template retirement = |
| 51 | new Transaction.Builder() |
| 52 | .addAction( |
| 53 | new Transaction.Action.SpendFromAccount() |
| 54 | .setAccountAlias("bob") |
| 55 | .setAssetAlias("gold") |
| 56 | .setAmount(5)) |
| 57 | .addAction(new Transaction.Action.Retire().setAssetAlias("gold").setAmount(5)) |
| 58 | .build(client); |
| 59 | Transaction.submit(client, HsmSigner.sign(retirement)); |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected