Skip to content

Commit f351495

Browse files
author
nashqueue
committed
Major Tutorial Upgrades
1 parent 8eb9216 commit f351495

File tree

1 file changed

+109
-10
lines changed

1 file changed

+109
-10
lines changed

tutorial.md

Lines changed: 109 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
697697

698698
3. Now that you've modified the file with the two updates, now it's safe to save the file.
699699

700-
## Use the CLI to create a post
700+
## Play with your Blog Chain - Create a Post
701701

702702
Now that you have implemented logic for creating and querying posts, you can interact with your blog chain using the command line. The blog chain binary is `blogd`.
703703

@@ -707,17 +707,18 @@ First, start the chain on your development machine by running the following comm
707707
ignite chain serve
708708
```
709709

710-
The binary is built by the `ignite chain serve` command bit it can also be built by running:
711-
712-
```bash
713-
ignite chain build
714-
```
715-
716710
To create a post at the command line:
717711

718712
```bash
719713
blogd tx blog create-post foo bar --from alice
720714
```
715+
where:
716+
717+
- blog is the module name
718+
- create-post is the message name
719+
- foo is the title
720+
- bar is the body
721+
- alice is the account that creates the post
721722

722723
The transaction is output to the terminal. You are prompted to confirm the transaction:
723724

@@ -728,9 +729,9 @@ confirm transaction before signing and broadcasting [y/N]: y
728729

729730
Type `y` to sign and broadcast the transaction.
730731

731-
Congratulations, you built a chain binary and used the `blogd` binary CLI to create a blog post.
732+
Congratulations, you used the `blogd` binary CLI to create a blog post.
732733

733-
## Use the CLI to query posts
734+
## Use the CLI to Query Posts
734735

735736
To query the list of all on-chain posts:
736737

@@ -743,13 +744,110 @@ The result:
743744
```bash
744745
Post:
745746
- body: bar
746-
creator: cosmos1ctxp3pfdtr3sw9udz2ptuh59ce9z0eaa2zvv6w
747+
creator: cosmos1a8chns8ay6vqfrgnq54cg7uzu8rlu2hk2uv06e
748+
downvotes: "0"
749+
id: "0"
750+
title: foo
751+
upvotes: "0"
752+
pagination:
753+
next_key: null
754+
total: "1"
755+
```
756+
757+
## Use the CLI to Update a Post and Query the Result
758+
759+
To update a post at the command line use:
760+
761+
```bash
762+
blogd tx blog update-post 0 newbody --from alice
763+
```
764+
765+
where:
766+
767+
- blog is the module name
768+
- update-post is the message name
769+
- 0 is the index of the post that gets the body changed
770+
- newbody is the new body
771+
- alice is the account that updates the post. If bob tries to update a post from alice an error occurs.
772+
773+
The transaction is output to the terminal. You are prompted to confirm the transaction:
774+
775+
```bash
776+
{"body":{"messages":[{"@type":"/blog.blog.MsgUpdatePost","creator":"cosmos1a8chns8ay6vqfrgnq54cg7uzu8rlu2hk2uv06e","index":"0","body":"newbody"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
777+
778+
confirm transaction before signing and broadcasting [y/N]:
779+
```
780+
Type `y` to sign and broadcast the transaction.
781+
782+
Query the list of all on-chain posts to see the updated body:
783+
784+
```bash
785+
blogd q blog posts
786+
```
787+
788+
The result:
789+
790+
```
791+
Post:
792+
- body: newbody
793+
creator: cosmos1a8chns8ay6vqfrgnq54cg7uzu8rlu2hk2uv06e
794+
downvotes: "0"
795+
id: "0"
796+
title: foo
797+
upvotes: "0"
798+
pagination:
799+
next_key: null
800+
total: "1"
801+
```
802+
Congratulations, you just used the `blogd` binary CLI to update a blog post and see the result with a query.
803+
804+
## Use the CLI to Vote on a Post and Query the Result
805+
806+
To vote on a post at the command line use:
807+
808+
```bash
809+
blogd tx blog vote-on-post 0 1 2 --from bob
810+
```
811+
812+
where:
813+
814+
- blog is the module name
815+
- vote-on-post is the message name
816+
- 0 is the index of the post that gets the body changed
817+
- 1 is the number of upvotes
818+
- 2 is the number of downvote
819+
- bob is the account that votes on the post
820+
821+
The transaction is output to the terminal. You are prompted to confirm the transaction:
822+
823+
```bash
824+
{"body":{"messages":[{"@type":"/blog.blog.MsgVoteOnPost","creator":"cosmos1ww26u0md05sux2gvtznkurrw4ywrc0r06sqscq","index":"0","upvotes":"1","downvotes":"2"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
825+
826+
confirm transaction before signing and broadcasting [y/N]:
827+
```
828+
Type `y` to sign and broadcast the transaction.
829+
830+
Query the list of all on-chain posts to see the updated votes:
831+
832+
```bash
833+
blogd q blog posts
834+
```
835+
836+
The result:
837+
838+
```
839+
Post:
840+
- body: newbody
841+
creator: cosmos1a8chns8ay6vqfrgnq54cg7uzu8rlu2hk2uv06e
842+
downvotes: "2"
747843
id: "0"
748844
title: foo
845+
upvotes: "1"
749846
pagination:
750847
next_key: null
751848
total: "1"
752849
```
850+
Congratulations, you just used the `blogd` binary CLI to vote on a blog post and see the result with a query.
753851

754852
## Conclusion
755853

@@ -758,6 +856,7 @@ Congratulations. You have built a blog blockchain!
758856
You have successfully completed these steps:
759857

760858
* Write blog posts to your chain
859+
* Update and vote on blog posts
761860
* Read from blog posts
762861
* Scaffold a Cosmos SDK message
763862
* Define new types in protocol buffer files

0 commit comments

Comments
 (0)