Skip to content

Commit 1d0bb5b

Browse files
authored
Merge pull request #79 from mlabs-haskell/rmgaray/fix-shop-tutorial-title
fix: shop tutorial title
2 parents a2ad85c + a8d3393 commit 1d0bb5b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/Shop Tutorial.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Outline for Shop tutorial
1+
# Shop tutorial
22

33
## Introduction
44

@@ -48,7 +48,7 @@ The SDK provides wallets in the form of `SingleAddressWallet` and `OnlineWallet`
4848

4949
### How wallets are handled in the demo
5050

51-
In the demo, the wallet is loaded via a singleton class. This is chosen as a simple a example of how to initialize the user's wallet and allow it to persist between multiple scenes and is assumed to be the most general approach for a blockchain game. It also allows better management of queries by enabling caching, where loading a new wallet per scene may mean additional queries. Other approaches may still be preferred depending on the particular needs of a game.
51+
In the demo, the wallet is loaded via a singleton class. This is chosen as a simple a example of how to initialize the user's wallet and allow it to persist between multiple scenes and is assumed to be the most general for a blockchain game. It also allows better management of queries by enabling caching, where loading a new wallet per scene may mean additional queries. Other approaches may still be preferred depending on the particular needs of a game.
5252

5353
For the purposes of the demo, the user's password is simply hardcoded in-place as a string literal. This choice allows for a smoother demonstration, but is naturally not recommended for real-world use. It is recommended that your game require the user to select a sufficiently complex password to encrypt their private key on wallet creation, and to intermittently prompt the user for their password during the game. Depending on your game, it may also be acceptable to prompt the user for their password every time they sign a transaction.
5454

@@ -224,6 +224,7 @@ This approach is not without its disadvantages, though: to keep the number of co
224224
We can see an example of adding constraints in `mint_tokens`. All constraints are implemented as methods of the `TxBuilder` class:
225225

226226
```python
227+
227228
func mint_tokens() -> bool:
228229
busy = true
229230
var shop_address := provider.make_address(
@@ -279,7 +280,7 @@ func mint_tokens() -> bool:
279280
Here we are:
280281

281282
- Adding a minting constraint: `mint_cip68_pair` makes sure that the generated TX mints a valid pair of CIP68 tokens (in this case, one reference token and multiple fungible user tokens).
282-
- Adding two paying constraints: `pay_cip68_ref_token` sets the destination address of the reference token to the ref lock script. `pay_cip68_user_tokens_with_datum` sets the destination address of the user tokens to the shop script, while also specifying the datum the output should have (the owner’s PubKeyHash). Notice that the first constraint conveniently sets the datum of the reference token: this is necessary for any CIP68 reference token, so it is handled automatically.
283+
- Adding two paying constraints: `pay_cip68_ref_token` sets the destination address of the reference token to the shop script. `pay_cip68_user_tokens_with_datum` does the same, while also specifying the datum the output should have (the owner’s PubKeyHash). Notice that the first constraint conveniently sets the datum of the reference token: this is necessary for any CIP68 reference token, so it is handled automatically.
283284

284285
This function should also be a good example of all the points at which errors may be reported via `Result`s in the process of building, signing, and submitting a transaction.
285286

@@ -330,7 +331,7 @@ func load_script_and_create_ref(filename: String) -> PlutusScriptSource:
330331
func(tx_builder: TxBuilder):
331332
tx_builder.pay_to_address(
332333
provider.make_address(
333-
Credential.from_script_source(ref_lock_source)
334+
Credential.from_script_source(source)
334335
),
335336
BigInt.zero(),
336337
MultiAsset.empty(),
@@ -349,7 +350,7 @@ func load_script_and_create_ref(filename: String) -> PlutusScriptSource:
349350
return source
350351
```
351352

352-
In addition, you can provide a `ScriptResource` as the "Minting Policy" field of a `Cip68Config` resource and (after calling `Cip68Config.init_script`) allow the `TxBuilder` to handle the script requirements with the CIP68 helper methods provided. This usage can be seen in the demo under `res://cip68_data/`. The helper functions include:
353+
In addition, you can provide a `ScriptResource` as the "Minting Policy" field of a `Cip68Config` resource and (after calling `Cip68Config.init_script`) allow the `TxBuilder` to handle the script requirements with the CIP68 helper methods provided:
353354

354355
```python
355356
func mint_cip68_pair(redeemer: PlutusData, conf: Cip68Config) -> TxBuilder:
@@ -372,6 +373,8 @@ func pay_cip68_user_tokens_with_datum(
372373
) -> TxBuilder:
373374
```
374375

376+
This usage can also be seen in the demo under `res://cip68_data/`.
377+
375378
The scripts provided in the demo each take a tag argument used to generate unique addresses and policy IDs. You can generate a unique shop of which your wallet is the owner by changing the tag to a number that has not yet been used. This tag can be found in the demo as `res://cip68_data/scripts_tag.tres`
376379

377380
### Script evaluation

0 commit comments

Comments
 (0)