|
| 1 | +--- |
| 2 | +title: Basic Usage |
| 3 | +sidebar: |
| 4 | + order: 3 |
| 5 | +--- |
| 6 | + |
| 7 | +In terminal, run the node in development mode: |
| 8 | + |
| 9 | +```bash |
| 10 | +./target/release/griffin-solochain-node --dev |
| 11 | +``` |
| 12 | + |
| 13 | +In another terminal, one can interact with the node by issuing wallet commands. Every time the wallet starts (without the `--help` or `--version` command-line options), it will try to synchronize its database with the present chain state, unless there is a mismatch with the genesis hash. |
| 14 | + |
| 15 | +To list the whole UTxO set, run |
| 16 | + |
| 17 | +```bash |
| 18 | +./target/release/griffin-wallet show-all-outputs |
| 19 | +``` |
| 20 | + |
| 21 | +When this is done for the first, the output will look like this: |
| 22 | + |
| 23 | +``` |
| 24 | +[2024-11-14T12:37:20Z INFO griffin_wallet] Number of blocks in the db: 5 |
| 25 | +[2024-11-14T12:37:20Z INFO griffin_wallet] Wallet database synchronized with node to height 6 |
| 26 | +###### Unspent outputs ########### |
| 27 | +998f074b5357d465fdd99198c65af6a418522e5a1688e2674c935702fef38d0600000000: owner address 6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4, datum Some(CuteOutput), amount: 314000000 Coins, Multiassets: |
| 28 | + (0x0298…2005) tokenA: 271000000 |
| 29 | + (0x0298…2005) tokenB: 1123581321 |
| 30 | +``` |
| 31 | +This “genesis” UTxO belongs to Shawn's address. In order to spend it, we need to add his public/secret key pair (pk/sk) to the wallet keystore. We do this by generating the pair with the corresponding seed phrase: |
| 32 | + |
| 33 | +``` |
| 34 | +$ ./target/release/griffin-wallet insert-key "news slush supreme milk chapter athlete soap sausage put clutch what kitten" |
| 35 | +
|
| 36 | +[2024-11-14T12:38:19Z INFO griffin_wallet] Number of blocks in the db: 6 |
| 37 | +[2024-11-14T12:38:19Z INFO griffin_wallet] Wallet database synchronized with node to height 26 |
| 38 | +The generated public key is 7b155093789404780735f4501c576e9f6e2b0a486cdec70e03e1ef8b9ef99274 (5Er65XH4...) |
| 39 | +Associated address is 0x6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4 |
| 40 | +``` |
| 41 | + |
| 42 | +We use the `generate-key` command to have another pk/sk and address available for experimenting. |
| 43 | + |
| 44 | +``` |
| 45 | +$ ./target/release/griffin-wallet generate-key |
| 46 | +
|
| 47 | +[2024-11-14T12:38:53Z INFO griffin_wallet] Number of blocks in the db: 26 |
| 48 | +[2024-11-14T12:38:53Z INFO griffin_wallet] Wallet database synchronized with node to height 37 |
| 49 | +Generated public key is 3538f889235842527b946255962241591cdc86cb99ba566afde335ae94262ee4 (5DGVKT7k...) |
| 50 | +Generated Phrase is "vibrant assume service vibrant six unusual trumpet ten truck raise verify soft" |
| 51 | +Associated address is 0x614fdf13c0aabb2c2e6df7a0ac0f5cb5aaabca448af8287e54681273dd |
| 52 | +``` |
| 53 | + |
| 54 | +Now we spend the output, generating a new UTxO for the last address: |
| 55 | + |
| 56 | +``` |
| 57 | +$ ./target/release/griffin-wallet spend-value --input 998f074b5357d465fdd99198c65af6a418522e5a1688e2674c935702fef38d0600000000 --amount 200000000 --recipient 0x614fdf13c0aabb2c2e6df7a0ac0f5cb5aaabca448af8287e54681273dd |
| 58 | +
|
| 59 | +[2024-11-14T12:41:18Z INFO griffin_wallet] Number of blocks in the db: 37 |
| 60 | +[2024-11-14T12:41:18Z INFO griffin_wallet] Wallet database synchronized with node to height 86 |
| 61 | +Note: Excess input amount goes to Shawn. |
| 62 | +[2024-11-14T12:41:18Z INFO griffin_wallet::money] Node's response to spend transaction: Ok("0x5a1974d3e3d32c075b220513125c9457ac9efc59a651d36704c0c7a4e389b6e6") |
| 63 | +Transaction queued. When accepted, the following UTxOs will become available: |
| 64 | +"dcb998d9e000c19fd20e41afeff6e1e0d9366e6e6c756c8173e52fc8061638f600000000" worth Coin(200000000). |
| 65 | +"dcb998d9e000c19fd20e41afeff6e1e0d9366e6e6c756c8173e52fc8061638f601000000" worth Multiasset(114000000, EncapBTree({0x0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005: EncapBTree({AssetName("tokenA"): 271000000, AssetName("tokenB"): 1123581321})})). |
| 66 | +``` |
| 67 | + |
| 68 | +All command-line arguments admit short versions (run `./target/release/griffin-wallet -h` for details). The next invocation spends the first UTxO and sends some coins back to Shawn: |
| 69 | + |
| 70 | +``` |
| 71 | +$ ./target/release/griffin-wallet spend-value --input dcb998d9e000c19fd20e41afeff6e1e0d9366e6e6c756c8173e52fc8061638f600000000 --amount 150000000 --witness 3538f889235842527b946255962241591cdc86cb99ba566afde335ae94262ee4 |
| 72 | +
|
| 73 | +[2024-11-14T12:47:45Z INFO griffin_wallet] Number of blocks in the db: 184 |
| 74 | +[2024-11-14T12:47:45Z INFO griffin_wallet] Wallet database synchronized with node to height 215 |
| 75 | +Note: Excess input amount goes to Shawn. |
| 76 | +[2024-11-14T12:47:45Z INFO griffin_wallet::money] Node's response to spend transaction: Ok("0xbcc0e3f157c660e022890ea9a8ddf1e7a324dd7ae30496a774d4f04046b5097a") |
| 77 | +Transaction queued. When accepted, the following UTxOs will become available: |
| 78 | +"bf73bc5bcf3afa75a7070041c635d78f6613aa3b753956e93053077cf9dc4b8e00000000" worth Coin(150000000). |
| 79 | +"bf73bc5bcf3afa75a7070041c635d78f6613aa3b753956e93053077cf9dc4b8e01000000" worth Coin(50000000). |
| 80 | +``` |
| 81 | + |
| 82 | +In this second example, we had to explicitly state the pk of the owning address to allow spenditure; in order to be successful, the sk must be stored in the wallet's keystore. (If the `--witness` argument is missing, Shawns pk is implied, cf. the first spend.) |
| 83 | + |
| 84 | +The UTxO set at this point is |
| 85 | + |
| 86 | +``` |
| 87 | +$ ./target/release/griffin-wallet show-all-outputs |
| 88 | +
|
| 89 | +[2024-11-14T12:48:44Z INFO griffin_wallet] Number of blocks in the db: 215 |
| 90 | +[2024-11-14T12:48:44Z INFO griffin_wallet] Wallet database synchronized with node to height 234 |
| 91 | +###### Unspent outputs ########### |
| 92 | +bf73bc5bcf3afa75a7070041c635d78f6613aa3b753956e93053077cf9dc4b8e00000000: owner address 6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4, datum None, amount: 150000000 Coins |
| 93 | +bf73bc5bcf3afa75a7070041c635d78f6613aa3b753956e93053077cf9dc4b8e01000000: owner address 6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4, datum None, amount: 50000000 Coins |
| 94 | +dcb998d9e000c19fd20e41afeff6e1e0d9366e6e6c756c8173e52fc8061638f601000000: owner address 6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4, datum None, amount: 114000000 Coins, Multiassets: |
| 95 | + (0x0298…2005) tokenA: 271000000 |
| 96 | + (0x0298…2005) tokenB: 1123581321 |
| 97 | +
|
| 98 | +``` |
| 99 | + |
| 100 | +Finally, to send some coins *and* `tokenA`s from the last UTxO to the other account, we do: |
| 101 | +``` |
| 102 | +$ ./target/release/griffin-wallet spend-value --input dcb998d9e000c19fd20e41afeff6e1e0d9366e6e6c756c8173e52fc8061638f601000000 --amount 14000000 --policy 0x0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005 --name tokenA --token-amount 200000000 --recipient 0x614fdf13c0aabb2c2e6df7a0ac0f5cb5aaabca448af8287e54681273dd |
| 103 | +
|
| 104 | +[2024-11-14T12:54:28Z INFO griffin_wallet] Number of blocks in the db: 250 |
| 105 | +[2024-11-14T12:54:28Z INFO griffin_wallet] Wallet database synchronized with node to height 349 |
| 106 | +Note: Excess input amount goes to Shawn. |
| 107 | +[2024-11-14T12:54:28Z INFO griffin_wallet::money] Node's response to spend transaction: Ok("0xa7ad4765e2ab4767e434fc6c117929a8871288c094a428164071c63bd9f0490a") |
| 108 | +Transaction queued. When accepted, the following UTxOs will become available: |
| 109 | +"ae2bcf3d0b2ace1f957176f17bac72e3fc2e518c82b41a9bdd622bb82318e4b200000000" worth Multiasset(14000000, EncapBTree({0x0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005: EncapBTree({AssetName("tokenA"): 200000000})})). |
| 110 | +"ae2bcf3d0b2ace1f957176f17bac72e3fc2e518c82b41a9bdd622bb82318e4b201000000" worth Multiasset(100000000, EncapBTree({0x0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005: EncapBTree({AssetName("tokenA"): 71000000, AssetName("tokenB"): 1123581321})})). |
| 111 | +``` |
| 112 | + |
| 113 | +The *balance* summarizes `Value` amounts for each address: |
| 114 | + |
| 115 | +``` |
| 116 | +$ ./target/release/griffin-wallet show-balance |
| 117 | +
|
| 118 | +[2024-11-14T12:54:34Z INFO griffin_wallet] Number of blocks in the db: 349 |
| 119 | +[2024-11-14T12:54:34Z INFO griffin_wallet] Wallet database synchronized with node to height 351 |
| 120 | +Balance Summary |
| 121 | +6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4: 300000000 Coins, Multiassets: |
| 122 | + (0x0298…2005) tokenA: 71000000 |
| 123 | + (0x0298…2005) tokenB: 1123581321 |
| 124 | +614fdf13c0aabb2c2e6df7a0ac0f5cb5aaabca448af8287e54681273dd: 14000000 Coins, Multiassets: |
| 125 | + (0x0298…2005) tokenA: 200000000 |
| 126 | +-------------------- |
| 127 | +total : 314000000 Coins, Multiassets: |
| 128 | + (0x0298…2005) tokenA: 271000000 |
| 129 | + (0x0298…2005) tokenB: 1123581321 |
| 130 | +``` |
0 commit comments