You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/md/en/docs/tutorials/build-application-logic/add-a-pallet.md
+20-41
Original file line number
Diff line number
Diff line change
@@ -286,7 +286,7 @@ To start the local Substrate node:
286
286
287
287
## Start the front-end template
288
288
289
-
Now that you have added a new pallet to your runtime, you can use the [Substrate front-end template](/tutorials/build-a-blockchain/build-local-blockchain/#install-the-front-end-template) to interact with the node template and access the Nicks pallet.
289
+
Now that you have added a new pallet to your runtime, you can use the [Substrate front-end template](/tutorials/build-a-blockchain/build-local-blockchain/#install-the-front-end-template)or [Polkadot/Substrate Portal](https://polkadot.js.org/apps/#/explorer?rpc=ws://localhost:9944) (used in this tutorial) to interact with the node template and access the Lottery pallet.
290
290
291
291
To start the front-end template:
292
292
@@ -302,62 +302,41 @@ To start the front-end template:
302
302
303
303
1. Open `http://localhost:8000/` in a browser to view the front-end template.
304
304
305
-
## Set a nickname using the Nicks pallet
305
+
## Launch a lottery using the Lottery pallet
306
306
307
-
After you start the front-end template, you can use it to interact with the Nicks pallet you just added to the runtime.
307
+
After you start the front-end template, you can use it to interact with the Lottery pallet you just added to the runtime.
308
308
309
-
To set a nickname for an account:
309
+
To set startLottery's parameters:
310
310
311
-
1.Check the account selection list to verify that the Alice account is currently selected.
311
+
1.According to our configuration, we need to have administrative privileges. In the `Developer` menu, verify that **Sudo** is selected.
312
312
313
-
1. In the Pallet Interactor component, verify that **Extrinsic** is selected.
313
+
2. Select **lottery** from the list of pallets available to call.
314
314
315
-
2. Select **nicks**from the list of pallets available to call.
315
+
3. Select **startLottery**as the function to call from the lottery pallet.
316
316
317
-
3. Select [**setName**](https://paritytech.github.io/substrate/master/pallet_nicks/pallet/enum.Call.html#variant.set_name) as the function to call from the nicks pallet.
317
+
4. Set up a new lottery by filling up the 4 parameters:
318
318
319
-
4. Type a **name** that is longer than the `MinNickLength` (8 characters) and no longer than the `MaxNickLength` (32 characters).
319
+
-`price`: The cost of a single ticket.
320
+
-`length`: How long the lottery should run for starting at the current block.
321
+
-`delay`: How long after the lottery end we should wait before picking a winner.
322
+
-`repeat`: If the lottery should repeat when completed.
320
323
321
-

324
+

322
325
323
-
5. Click **Signed** to execute the function.
326
+
5. Click **Submit Sudo** to execute the function.
324
327
325
-
6. Observe the status of the call change from Ready to InBlock to Finalized and the note the [events](https://paritytech.github.io/substrate/master/pallet_nicks/pallet/enum.Event.html) emitted by the Nicks pallet.
328
+
6. Observe the status of the call change from Ready to InBlock to Finalized and the note the events emitted by the Lottery pallet.
326
329
327
-

328
-
329
-
## Query information for an account using the Nicks pallet
330
-
331
-
Next, you can use Query capability to read the value of Alice's nickname from the runtime storage for the Nicks pallet.
332
-
333
-
To return the information stored for Alice:
334
-
335
-
1. In the Pallet Interactor component, select **Query** as the Interaction Type.
336
-
337
-
1. Select **nicks** from the list of pallets available to query.
338
-
339
-
1. Select [**nameOf**](https://paritytech.github.io/substrate/master/pallet_nicks/pallet/enum.Call.html#variant.set_name) as the function to call.
340
-
341
-
1. Copy and paste the address for the **alice** account in the AccountId field, then click **Query**.
342
-
343
-

344
-
345
-
The return type is a tuple that contains two values:
346
-
347
-
- The hex-encoded nickname for the Alice account `53756273747261746520737570657273746172202d20416c696365`.
348
-
If you convert the hex-encoded value to a string, you'll see the name you specified for the `setName` function.
349
-
- The amount that was reserved from Alice's account to secure the nickname (`100`).
350
-
351
-
If you were to query the Nicks pallet for the `nameOf` for Bob's account, you would see the value `None` returned because Bob has not invoked the `setName` function to reserve a nickname.
This tutorial illustrates how to add a simple pallet to the runtime and demonstrates how to interact with the new pallet using the predefined front-end template.
356
-
In this case, you added the `nicks` pallet to the runtime and called the `set_name` and `nameOf` functions using the front-end template.
357
-
The `nicks` pallet also provides two additional functions—the `clear_name` function and the `kill_name` function—that enable an account owner to remove the reserved name or a root-level user to forcibly remove an account name.
358
-
You can learn about additional features—such as the use of the Sudo pallet and origin accounts—by exploring how these functions work.
335
+
In this case, you added the `lottery` pallet to the runtime and called the `start_lottery` functions using the front-end template.
336
+
The `lottery` pallet also provides other functions like the `stop_repeat` function.
337
+
You can learn about additional features—such as giving Alice account the Sudo privileges.
359
338
However, these features are beyond the intended scope of this tutorial.
360
-
If you want to explore additional features exposed through the Nicks and Sudo pallets, see [Next steps](#next-steps) and select [Specify the origin for a call](/tutorials/build-application-logic/specify-the-origin-for-a-call).
339
+
If you want to explore additional features exposed through the Lottery and Sudo pallets, see [Next steps](#next-steps) and select [Specify the origin for a call](/tutorials/build-application-logic/specify-the-origin-for-a-call).
0 commit comments