Skip to content

Commit 6ab5455

Browse files
E2e app (#3)
* feat: add colored output for unspent tree printing * feat: update UTxOError to include PhaseTwo validation errors * fixed command name in README * feat: add ttl field to TransactionBody and propagate it in conversions * feat: refactor genesis configuration including `zero_time` & `zero_slot` * feat: add transaction validity interval check and expose helper functions for zero time and slot * feat: update phase two checks to use custom slot configuration * feat: log genesis posix time and wait until genesis time in service initialization * feat: add docs directory * feat: add documentation for Order Book dApp including introduction, usage, and building instructions * feat: update README to reflect changes in script payment and spending commands * feat: update .gitignore to include additional Aiken project files and directories * feat: add order book contract files including types, utils, and validators * feat: update validator and redeemer files for EUTXO examples in wallet * feat: include control token class in order print output * feat: remove ex_units field from Redeemer and related usages * feat: add Alice's key details and update genesis configuration with new address * feat: extend `pay-to-script` and `spend-script` commands * feat: update documentation for `pay-to-script` and `spend-script` commands with new parameters and examples * fix: update image paths in introduction documentation for correct rendering
1 parent 7cae2b8 commit 6ab5455

52 files changed

Lines changed: 1796 additions & 422 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
target/
22
**/*~
3-
settings.json
3+
settings.json
4+
5+
# Aiken compilation artifacts
6+
artifacts/
7+
# Aiken's project working directory
8+
build/
9+
10+
plutus.json
11+
aiken.lock

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Development chains are set to
6363
- are preconfigured with a genesis state (/node/src/chain_spec.rs).
6464

6565

66-
To preserve the chain state between runs, specify a base path by running a command similar to the following:
66+
To preserve the chain state between runs, specify a base path as follows:
6767

6868
```bash
6969
// Create a folder to use as the db base path
@@ -111,6 +111,7 @@ If you get a `NetworkKeyNotFound` error, you can run once `./target/release/grif
111111
```
112112

113113
where `<AUTHORING_NODE_IDENTITY>` should be replaced by the appropriate id.
114+
114115
4. The wallet will talk to the node having `--rpc-port` equal to 9944.
115116

116117
It might be necessary to delete the nodes' DBs (through the `purge-chain` command or manually, e.g., by erasing the `/tmp/hola` folder for the listening node) if this is not first time the node is run *locally*.

docs/assets/cancelOrder.png

334 KB
Loading

docs/assets/resolveOrder.png

347 KB
Loading

docs/assets/startOrder.png

108 KB
Loading

docs/content/demo_wallet/_meta.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
label: Demo Wallet
2+
order: 5
3+
collapsed: true
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
```

docs/content/demo_wallet/eutxo.mdx

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: E-UTxO Commands
3+
sidebar:
4+
order: 4
5+
---
6+
7+
### Paying to a Script Address
8+
9+
This command pays some coins and assets to the script specified by `validator-hex-file`. The optional parameters `validator_params_cbor_file` and `datum-cbor-file` are used to pass the files containing the cbor of the parameter list expected by a parameterized script (if any) and the cbor of the inline datum to be included in the script output, if any. We also specify a list of wallet inputs to be consumed by this transaction, and with `witness` the public key of an input owner (Shawn's pk implied by default). We can set as many inputs, witnesses and combinations of (policy, name, token-amount) as needed.
10+
11+
If minting an asset, the path to the file containing the minting policy script hex, the file of the parameter list cbor to be applied (if any) and the file containing the minting policy redeemer cbor. Also the minted asset name and amount.
12+
13+
The whole command looks like this:
14+
15+
```bash
16+
./target/release/griffin-wallet pay-to-script \
17+
--validator-hex-file PATH_TO_VALIDATOR_SCRIPT_HEX \
18+
--validator-params-cbor-file PATH_TO_VALIDATOR_PARAM_LIST_CBOR \
19+
--datum-cbor-file PATH_TO_DATUM_CBOR \
20+
--input [INPUT_REF] \
21+
--policy-hex-file PATH_TO_MINTING_POLICY_SCRIPT_HEX \
22+
--policy-params-cbor-file PATH_TO_MINTING_POLICY_PARAM_LIST_CBOR \
23+
--policy-redeemer-cbor-file PATH_TO_MINTING_POLICY_REDEEMER_CBOR \
24+
--minted-asset-name [BURNT_ASSET_NAME] \
25+
--minted-asset-amount TOKEN_AMOUNT \
26+
--output-coin-amount COIN_AMOUNT \
27+
--output-asset-policy [POLICY_ID] \
28+
--output-asset-name [ASSET_NAME] \
29+
--output-asset-amount [TOKEN_AMOUNT] \
30+
--required-signer [REQUIRED_SIGNER] \
31+
--witness [WITNESS]
32+
```
33+
34+
For example, we can pay 2000 coins to the plutusV2 script version of [aiken's "hello-world" example](https://aiken-lang.org/example--hello-world/basics), spending an input that belongs to Shawn (its ref may vary) and with an inline datum that contains Shawn's pub key hash, like so:
35+
36+
```bash
37+
./target/release/griffin-wallet pay-to-script \
38+
--validator-hex-file ./wallet/src/eutxo_examples/hello_world/validator.txt \
39+
--datum-cbor-file ./wallet/src/eutxo_examples/hello_world/datum.txt \
40+
--input 600b207f1a6a2a316ac010c9fd42587df206dee24a6025bc87d9c5f7229b0d3e00000000 \
41+
--output-coin-amount 2000
42+
```
43+
44+
### Spending a Script UTxO
45+
46+
In order to spend a script UTxO, we need to specify the file containing the script hex, the file of the parameter list cbor to be applied (if any), the file containing the validator redeemer cbor, the script input to be consumed.
47+
48+
If burning an asset, the path to the file containing the minting policy script hex, the file of the parameter list cbor to be applied (if any) and the file containing the minting policy redeemer cbor. Also the burnt asset name and amount.
49+
50+
We can also set an arbitrary amount of wallet inputs, to be used to pay some value to some recipient. This value is specified by a coin amount and lists of asset policies, names and amounts,
51+
52+
Optionally we can set a validity interval start and the required signer(s) and witness(es) (if omitted, Shawn's values go as default).
53+
54+
The complete command looks like this:
55+
56+
```bash
57+
./target/release/griffin-wallet spend-script \
58+
--script-input [INPUT_REF] \
59+
--validator-hex-file PATH_TO_VALIDATOR_SCRIPT_HEX \
60+
--validator-params-cbor-file PATH_TO_VALIDATOR_PARAM_LIST_CBOR \
61+
--validator-redeemer-cbor-file PATH_TO_VALIDATOR_REDEEMER_CBOR \
62+
--policy-hex-file PATH_TO_MINTING_POLICY_SCRIPT_HEX \
63+
--policy-params-cbor-file PATH_TO_MINTING_POLICY_PARAM_LIST_CBOR \
64+
--policy-redeemer-cbor-file PATH_TO_MINTING_POLICY_REDEEMER_CBOR \
65+
--burnt-asset-name [BURNT_ASSET_NAME] \
66+
--burnt-asset-amount TOKEN_AMOUNT \
67+
--wallet-input [INPUT_REF] \
68+
--output-coin-amount COIN_AMOUNT \
69+
--output-asset-policy [POLICY_ID] \
70+
--output-asset-name [ASSET_NAME] \
71+
--output-asset-amount [TOKEN_AMOUNT] \
72+
--output-recipient RECIPIENT_ADDRESS \
73+
--validity-interval-start SLOT_NUMBER \
74+
--required-signer [REQUIRED_SIGNER] \
75+
--witness [WITNESS]
76+
```
77+
78+
For instance, to spend the UTxO sitting at the "hello-world" address that we created in [Paying to a Script Address](#paying-to-a-script-address), we use the following command (the input script ref may vary):
79+
80+
```bash
81+
./target/release/griffin-wallet spend-script \
82+
--validator-hex-file ./wallet/src/eutxo_examples/hello_world/validator.txt \
83+
--validator-redeemer-cbor-file ./wallet/src/eutxo_examples/hello_world/redeemer.txt \
84+
--script-input ea87ef680553f8683ea9a515f933a96b63324befd0946b0c050f19f931e0c80800000000
85+
```
86+
87+
### Minting an Asset
88+
89+
To mint an asset with some policy id, we need to specify the minting script hex, the parameter list to be applied (if any), the redeemer, an input to be consumed (every tx needs at least one, and we also need to pay for the min amount of coins in the output containing the newly minted asset), the witness(es) and recipient (by default, Shawn's pk and address are implied), the name of the asset to mint and its amount:
90+
91+
```bash
92+
./target/release/griffin-wallet mint-asset \
93+
--script-hex-file PATH_TO_MINTING_POLICY_HEX \
94+
--script-params-cbor-file PATH_TO_PARAM_LIST_CBOR \
95+
--redeemer-cbor-file PATH_TO_REDEEMER_CBOR \
96+
--input [INPUT_REF] \
97+
--witness [WITNESS] \
98+
--recipient RECIPIENT_ADDRESS \
99+
--name ASSET_NAME \
100+
--token-amount MINT_AMOUNT
101+
```
102+
103+
As an example, we can mint a singleton with name "oneShot", for a plutusV2 script version of the "one-shot" minting policy (takes a ref input as a parameter, and if minting checks that `input_is_consumed && minted_amount == 1`, or just `minted_amount == -1` if burning). In this case we are sending the minted amount back to Shawn (if the input ref is different, you should replace it both in the parameter list cbor as in the `input` argument below):
104+
105+
```bash
106+
./target/release/griffin-wallet mint-asset \
107+
--script-hex-file ./wallet/src/eutxo_examples/one_shot_mp/script.txt \
108+
--script-params-cbor-file ./wallet/src/eutxo_examples/one_shot_mp/parameters.txt \
109+
--redeemer-cbor-file ./wallet/src/eutxo_examples/one_shot_mp/redeemer.txt \
110+
--input 76196d9dc867051484c523112f2c4861795566edd5817e41db15be0c4d556e8501000000 \
111+
--name oneShot \
112+
--token-amount 1
113+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Installation
3+
sidebar:
4+
order: 2
5+
---
6+
7+
## Installation
8+
9+
You should have a properly installed Griffin node to build the wallet. After following the [instructions to do that](https://github.com/txpipe/griffin/blob/main/README.md#installation), run
10+
11+
```bash
12+
cargo build --release -p griffin-wallet
13+
```
14+
15+
As explained in the node installation instructions, omitting the `--release` will build the "debug" version.

0 commit comments

Comments
 (0)