POCKET-JS, the NodeJS POCKET confirmer

in #utopian-io6 years ago

Repository

https://github.com/quochuy/pocketjs

What is the project about?

POCKET stands for Proof Of Concept Electronic Token (the K is silent).

POCKET is a project by @biophil. In a nutshell, it is a cryptocurrency that uses the STEEM blockchain as a base. It uses STEEM comments to execute commands such as sending tokens and confirming them.

The distribution of POCKET tokens has already stopped but many people still own some tokens and distributing them as tips via comments.

I started this project after seeing @sn0n asking @biophil if the project exists in Javascript on the following post:
https://steemit.com/pocket/@biophil/pocket-announcement#@sn0n/re-biophil-pocket-announcement-20180112t011307004z

The original implementation of the POCKET confirmer was developed with Python.

Screenshots

Here is a screenshot of @pode sending some POCKET to @dmaniabot via a comment. The transaction was then confirmed by @pocketjs

Screen Shot 2018-07-06 at 6.16.34 pm.png


Here is the activity logs from the bot:
Screen Shot 2018-07-06 at 6.19.07 pm.png


Here is a recent activity logs from https://steemd.com/@pocketjs:
Screen Shot 2018-07-06 at 6.21.35 pm.png

Technology Stack

  • Javascript
  • NodeJS
  • dsteem
  • JSON format for the file-based database
  • Docker + Docker Compose

Installation

Using GIT, clone the repository: git clone https://github.com/quochuy/pocketjs.git

Customizing the config file

  • make a copy of bot/config/config.distrib.json and name it config.json
  • edit the file and update set confirmer_account to your bot's Steem account username and confirmer_key to your bot's Steem private posting key
  • you might want to also set mode.test to true and mode.debug to 1 or 2 to increase log verbosity.

Once the confirmer is caught up with the head of the blockchain, you can set confirmation_active to true.

Running with NodeJS

You need to install NodeJS and then run the bot:

  • cd /path/to/project/bot
  • node confirmer.js

Running with Docker

You will need to install Docker and Docker Compose first then build the bot:

  • cd /path/to/project/bot
  • docker-compose build

Once the build is successful, you can run the bot with: docker-compose up -d
Check the logs with: tail -f bot/logs/bot.log

Generating a DB snapshot from an existing running Python confirmer

If you are already running @biophil's original confirmer written in Python and would like to help test this project, you can generate your own DB snapshot by copying the following file under the same directory as the blockchain_reader.py file:
https://github.com/quochuy/pocketjs/blob/master/bot/utils/convertDb.py

Then just run: python3 convertDb.py and this will generate a db.json file that you can just move into the bot/database/ directory of the POCKET-JS project.

Roadmap

The current version has been running fine for a couple of weeks already under @pocketjs but there are still few missing features:

  • replaying from block #1
  • replaying from Genesis
  • upvoting confirmation comments from other confirmers
  • rotate RPC nodes in case of connection issue
  • don't upvote or send confirmation comment until the replay reaches the head of the blockchain to prevent upvote/comment spamming

To run this script, it requires a post-genesis snapshot of the database. The GIT repository is currently hosting a DB snapshot as of 2018-07-06 at 6:00 pm AEST.

Ideas for extra features:

  • add an extra command (not part of the protocol) to allow requesting for an account balance: pocketbalance@user
  • create a simple blockchain explorer for POCKET

How to contribute?

Please contact me on Discord, my username is QuocHuy [witness]#4676

GitHub Account

https://github.com/quochuy

Sort:  

It's nice to revive project and not let them decay!
Let's hope it will be used :p

Let's go for the review:

This a great job overall!

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

@gregory.latinier ARG! I thought I filtered out that from the history already! Thanks for letting me know!
And thanks for the very thorough review!

That was fast. Congrats @quochuy <3

To answer the other questions:

  • password changed, thanks again
  • && instead of elses is because I did a straight port from Python to JS https://github.com/biophil/pocket/blob/master/blockchain_reader.py#L135 and I haven't yet gone thru code optimization and rewrite as the primary goal is to get the JS version up and running with the same logic. So keeping things as close as possible to the original makes it easier if I spot a behavior that is different from the Python version.
  • The tests were very useful as I get to change code here and there as I go, this allowed me to make sure that I didn't break anything with the new changes and refactor.
  • hahaha, I'm often working on a train and then forget to commit as I rush down, three days later... can't remember things. Advice taken :-)
  • I do almost everything with Docker as it makes it so much easier to deploy or migrate

Thanks again @gregory.latinier

Hey @quochuy
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by QuocHuy [witness] from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

@quochuy
Thanks for the information

Thx for this article! really interesting.

that follow the projects that make us grow more on the platform

pocketsend:11@steemulant,test

Successful Send of 11
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1024
New receiving account balance: 438
Fee: 1
Steem trxid: f31af5cd19747f24748861cef6aac54dc9c23be2
Thanks for using POCKET! I am running this confirmer code.

Successful Send of 11
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1024
New receiving account balance: 438
Fee: 1
Steem trxid: f31af5cd19747f24748861cef6aac54dc9c23be2


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy

pocketsend:11@steemulant,test

Successful Send of 11
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1013
New receiving account balance: 448
Fee: 1
Steem trxid: edd1a6886e132bcfce806a5fc9fffdfb60b49fd3
Thanks for using POCKET! I am running this confirmer code.

Successful Send of 11
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1013
New receiving account balance: 448
Fee: 1
Steem trxid: edd1a6886e132bcfce806a5fc9fffdfb60b49fd3


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy

pocketsend:2@steemulant,test

Successful Send of 2
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1011
New receiving account balance: 449
Fee: 1
Steem trxid: 727c155978762036bb2913858b9ed211582133c0
Thanks for using POCKET! I am running this confirmer code.

Successful Send of 2
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1011
New receiving account balance: 449
Fee: 1
Steem trxid: 727c155978762036bb2913858b9ed211582133c0


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy

pocketsend:2@steemulant,test

Successful Send of 2
Sending Account: quochuy
Receiving Account: steemulant
New sending account balance: 1009
New receiving account balance: 450
Fee: 1
Steem trxid: 5637ac529890d3a8ddcdd44cd2fd7b803e91a678


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy

pocketsend:400@quochuy

Successful Send of 400
Sending Account: steemulant
Receiving Account: quochuy
New sending account balance: 50
New receiving account balance: 1408
Fee: 1
Steem trxid: 8c01de2469c409ab1093ad02fdcdae58f514fe19


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy

pocketsend:750@quochuy

Successful Send of 750
Sending Account: pocketjs
Receiving Account: quochuy
New sending account balance: 44
New receiving account balance: 2157
Fee: 1
Steem trxid: 270299ff3460d07fb4358077e8dcff5a175681ef


pocket-logo.png

Someone sent you some POCKET tokens. POCKET is an experimental sub-token system which operates on the Steem blockchain. It's like having a custom token without SMT. You can also send some to someone else by just commenting on a post with the following command: pocketsend:number_of_token@recipient_name,memo for example to send 10 tokens to @pocketjs, make a comment starting with: pocketsend:10@pocketjs,This is a gift

I am running Pocket-JS confirmer code. by Steem Witness @quochuy