# Create a poll post
Upon completing this challenge, you will be rewarded 100 Desmos Tokens.
Please note that in order to prevent spam, you will receive the reward just for the first poll post you create. No tokens will be awarded for later posts.
v0.3.0 we've implemented the possibility for users to create poll posts, which allow to easily know what other Desmos users think about a specific question.
# Creating your first poll
After you've followed the setup and you've created your Desmos account using the
desmoscli keys command, you are ready to create your first poll posts. To do so, run the following command:
desmoscli tx posts create "<Subspace>" "<Message>" true \ --poll-details "question=<Question>,mutiple-answers=<true/false>,allows-answer-edits=<true/false>,end-date=<Poll ending date>" \ --poll-answer <First answer> \ --poll-answer <Second answer> \ ... --from <your-key-name> --yes \ --chain-id <chain-id>
Before seeing an example of such command, let's see what all the different parts of it do:
<Subspace>: allows to specify which application should show this poll. It must be a SHA256 hash.
We suggest you using
4e188d9c17150037d5199bbdb91ae1eb2a78a15aca04cb35530cccb81494b36e(SHA256 hash of
desmos) as its value. Otherwise, you can create your own using any online SHA256 hashing tool.
--poll-detailsallows you to specify the details of the polls. It must contain the following data:
question: the question of the poll
date: the end date of your poll after which no further answers will be accepted, in RFC3339 format.
multiple-answers: a boolean indicating the possibility of multiple answers from users
allows-answers-edits: a boolean value that indicates the possibility to edit the answers in the future
--poll-answer, which indicates a provided answer of the poll.
Each answer should be provided using the
Here's an example of such command:
desmoscli tx posts create "4e188d9c17150037d5199bbdb91ae1eb2a78a15aca04cb35530cccb81494b36e" "Post with poll" true \ --poll-details "question=Which dog do you prefer?,multiple-answers=false,allows-answer-edits=true,end-date=2020-03-01T15:00:00.000Z" \ --poll-answer "Beagle" \ --poll-answer "Pug" \ --poll-answer "German Sheperd" \ --from jack --yes \ --chain-id morpheus-3000
Know more about posts
If you want to know more about posts and how they are composed of, including the poll data, please refer to the official Desmos documentation
Once you've run that command you will be asked to type the password you've chosen during the setup and after having inserted it properly you should see something like this:
height: 0 txhash: 0AC2DE8ABBBA27AC2C1C83E2D3070B426E3D8BB67589C8C4A6804A31516F4AA9 codespace: "" code: 0 data: "" rawlog: '' logs:  info: "" gaswanted: 0 gasused: 0 tx: null timestamp: ""
To make sure the transaction has been processed successfully, you can query it using the following command:
desmoscli query tx <hash> --trust-node --output json # Example # desmoscli query tx 0AC2DE8ABBBA27AC2C1C83E2D3070B426E3D8BB67589C8C4A6804A31516F4AA9 --trust-node --output json
This will return you the JSON representation of the transaction itself.
# Getting the reward
After you've created a poll, to make sure you receive your reward please following this procedure:
Create a fork of this repo inside your private GitHub profile.
If you do not know how to do it, follow the GitHub fork guide.
Pull the fork locally:
git clone https://github.com/<your-name>/primer.git ~/desmos-primer cd ~/desmos-primer1
Make sure your fork is up to date with the Primer repository:
git remote add upstream https://github.com/desmos-labs/primer.git git fetch upstream git rebase upstream/master1
Create a file named after your GitHub username containing the post creation transaction hash:
echo "<tx-hash>" >> ./phase-3/challenges/polls/<your-github-name> # Example # echo "0AC2DE8ABBBA27AC2C1C83E2D3070B426E3D8BB67589C8C4A6804A31516F4AA9" >> ./phase-3/challenges/polls/RiccardoM1
Commit the changes, push them to your forked repo and create a pull request. If you do not know how to create one, refer to the GitHub Pull Requests guide.