Skip to content

Usage

Creating an Order

Let’s say that Alice wants to place an order paying 2 Token A and expecting to receive 5 Token B. She will use her input to pay for the amount, and specify in the datum her pub key hash, the expected asset policy, name and amount, and the asset class of the control token:

Terminal window
./target/release/griffin-wallet build-tx \
--inputs-info ./wallet/src/eutxo_examples/order_book/create_order/inputs_info.json \
--outputs-info ./wallet/src/eutxo_examples/order_book/create_order/outputs_info.json \
--scripts-info ./wallet/src/eutxo_examples/order_book/scripts_info.json \
--mintings-info ./wallet/src/eutxo_examples/order_book/create_order/mintings_info.json \
--required-signer 547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6 \
--witness c6f58a018f5f4fba0eec76bb2d92cacab00eb6b548197925572c61c17b3e4edf

The contents of inputs_info.json, outputs_info.json, scripts_info.json and mintings_info.json are respectively as follows (inputs refs may vary):

[
{
"tx_hash": "600b207f1a6a2a316ac010c9fd42587df206dee24a6025bc87d9c5f7229b0d3e",
"index": 1
}
]
[
{
"address": "706372cd7adc3553240c5cf5e5b8e1e96998821ef8a9b897bfa9c7d5b3",
"coin": 2000,
"value": [
{
"policy": "0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005",
"assets": [ ["tokenA", 2] ]
},
{
"policy": "6372CD7ADC3553240C5CF5E5B8E1E96998821EF8A9B897BFA9C7D5B3",
"assets": [ ["controlToken", 1] ]
}
],
"datum": "D8799FD8799F581C547932E40A24E2B7DEB41F31AF21ED57ACD125F4ED8A72B626B3D7F6D8799FD8799F581C0298AA99F95E2FE0A0132A6BB794261FB7E7B0D988215DA2F2DE200546746F6B656E42FF05FFFFD8799F581C6372CD7ADC3553240C5CF5E5B8E1E96998821EF8A9B897BFA9C7D5B34C636F6E74726F6C546F6B656EFFFF"
},
{
"address": "61547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6",
"coin": 314148000,
"value": [
{
"policy": "0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005",
"assets": [ ["tokenA", 299999998], ["tokenB", 2000000000] ]
}
]
}
]
[
{
"script_hex": "59080c..."
}
]
[
{
"policy": "6372CD7ADC3553240C5CF5E5B8E1E96998821EF8A9B897BFA9C7D5B3",
"assets": [ ["controlToken", 1] ],
"redeemer_cbor": "D87980"
}
]

Printing Available Orders

Note that if we just print all the outputs with the show-all-outputs wallet command, we won’t be able to see the details of the order datum:

Terminal window
bc67bcf53c1355c09558b95ff02fc37dc7a4e69e22a5bc365cc87f9d2207858500000000:
script address: 706372cd7adc3553240c5cf5e5b8e1e96998821ef8a9b897bfa9c7d5b3,
datum: Some("d8799fd8799f581c547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6d8799fd8799f581c0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de200546746f6b656e42ff05ffffd8799f581c6372cd7adc3553240c5cf5e5b8e1e96998821ef8a9b897bfa9c7d5b34c636f6e74726f6c546f6b656effff"),
amount: 2000 Coins, Multiassets:
(0x0298…2005) tokenA: 2
(0x6372…d5b3) controlToken: 1

To see the details of the order, we can use the show-all-orders command:

Terminal window
###### Available Orders ###########
bc67bcf53c1355c09558b95ff02fc37dc7a4e69e22a5bc365cc87f9d2207858500000000:
SENDER_PH: 0x547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6
ORDERED_CLASS: AssetClass {
policy_id: 0x0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005,
asset_name: AssetName(
"tokenB",
),
}
ORDERED_AMOUNT: 5
CONTROL_TOKEN_CLASS: AssetClass {
policy_id: 0x6372cd7adc3553240c5cf5e5b8e1e96998821ef8a9b897bfa9c7d5b3,
asset_name: AssetName(
"controlToken",
),
}
VALUE: 2000 Coins, Multiassets:
(0x0298…2005) tokenA: 2
(0x6372…d5b3) controlToken: 1

Canceling an Order

Suppose Alice wants to cancel the order. She will specify the script input, the cancel redeemer, the burning of the control token and her credentials to prove ownership of the order:

Terminal window
./target/release/griffin-wallet build-tx \
--inputs-info ./wallet/src/eutxo_examples/order_book/cancel_order/inputs_info.json \
--outputs-info ./wallet/src/eutxo_examples/order_book/cancel_order/outputs_info.json \
--scripts-info ./wallet/src/eutxo_examples/order_book/scripts_info.json \
--mintings-info ./wallet/src/eutxo_examples/order_book/cancel_order/mintings_info.json \
--required-signer 547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6 \
--witness c6f58a018f5f4fba0eec76bb2d92cacab00eb6b548197925572c61c17b3e4edf

In this case, the contents of inputs_info.json, outputs_info.json and mintings_info.json are respectively as follows:

[
{
"tx_hash": "ded6bfad09094e0ffa5c4093e5635827434376d66540e07c564d73f275130c34",
"index": 0,
"redeemer_cbor": "d87a81d87980"
}
]
[
{
"address": "61547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6",
"coin": 2000,
"value": [
{
"policy": "0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005",
"assets": [ ["tokenA", 2] ]
}
]
}
]
[
{
"policy": "6372CD7ADC3553240C5CF5E5B8E1E96998821EF8A9B897BFA9C7D5B3",
"assets": [ ["controlToken", -1] ],
"redeemer_cbor": "D87980"
}
]

Resolving an Order

Now let’s say that Shawn wants to resolve the order and pay 5 Token B to Alice. He will specify the script input, a wallet input used to pay Alice, the resolve redeemer and the burning of the control token:

Terminal window
./target/release/griffin-wallet build-tx \
--inputs-info ./wallet/src/eutxo_examples/order_book/resolve_order/inputs_info.json \
--outputs-info ./wallet/src/eutxo_examples/order_book/resolve_order/outputs_info.json \
--scripts-info ./wallet/src/eutxo_examples/order_book/scripts_info.json \
--mintings-info ./wallet/src/eutxo_examples/order_book/resolve_order/mintings_info.json \
--required-signer 01e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4 \
--witness 7b155093789404780735f4501c576e9f6e2b0a486cdec70e03e1ef8b9ef99274

In this case, the contents of inputs_info.json, outputs_info.json and mintings_info.json are respectively as follows:

[
{
"tx_hash": "ded6bfad09094e0ffa5c4093e5635827434376d66540e07c564d73f275130c34",
"index": 0,
"redeemer_cbor": "d87a81d87a80"
},
{
"tx_hash": "600b207f1a6a2a316ac010c9fd42587df206dee24a6025bc87d9c5f7229b0d3e",
"index": 0
}
]
[
{
"address": "61547932e40a24e2b7deb41f31af21ed57acd125f4ed8a72b626b3d7f6",
"coin": 2000,
"value": [
{
"policy": "0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005",
"assets": [ ["tokenB", 5] ]
}
]
},
{
"address": "6101e6301758a6badfab05035cffc8e3438b3aff2a4edc6544b47329c4",
"coin": 314000000,
"value": [
{
"policy": "0298aa99f95e2fe0a0132a6bb794261fb7e7b0d988215da2f2de2005",
"assets": [ ["tokenA", 271000002], ["tokenB", 1123581316] ]
}
]
}
]
[
{
"policy": "6372CD7ADC3553240C5CF5E5B8E1E96998821EF8A9B897BFA9C7D5B3",
"assets": [ ["controlToken", -1] ],
"redeemer_cbor": "D87980"
}
]