npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ethereum_rps

v0.0.1

Published

This is and implementation of the chiroptera library for a rock, paper, scissors game.

Readme

Ethereum_RPS

This project is a game of Rock, Paper, Scissors over the Ethereum blockchain to demonstrated the Ethereum-Easy library Ethereum-Easy. Every interaction with the Ethereum blockchain in this game is done with the Ethereum-Easy library. In this README I will show you how to run the game and how it works under the hood.

Running the Game

After you git a copy of the game, open three terminal windows. The first is for RabbitMQ, which you will install and run with the directions under Requirements. Navigate below the src directory in the Ethereum_RPS folder with the other two windows. Start the game by entering:

node app.js <player_entry> <throw_entry>

<player_entry> : string This is either p1 or p2 for player 1 and player 2.
It doesn't matter which player you decide to be.

<throw_entry> : string This is the rock, paper, scissors throw you want to select. You can choose from 'rock', 'paper', or 'scissor'.

Note: It is helpful to start the nodes at relatively the same time.

Requirements

In order to run this game, you will need to have a working installation of RabbitMQ on your machine. This Rock, Paper, Scissors game uses Rabbit for passing AMQP messages between players in different Node windows. If you would like to run this game yourself, download RabbitMQ from the link provided and then run a broker on a terminal window with the instructions on their website under 'Getting Started'..

How it Works

Each node of this game enters different states as it progresses along its commitment scheme. The states are Ready, Deploying, Submitting Answer, Confirming Submissions, and Reveal. These follow a commitment scheme where each node checks the liveness of one another, a smart contract for the game is deployed, answers which have been run through a caesar cipher are committed to the blockchain, each node checks that the other has committed an answer, and finally the key to the caesar cipher is shared and each answer is decrypted. The details of each state are as follows:

Ready

In the Ready state, each node sends a message to each other verifying the other is ready to start the game.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----


 --------------                    --------------
|              |     MESSAGE      |              |
|              |  ------------>   |              |
|   PLAYER 1   |     MESSAGE      |   PLAYER 2   |
|    READY!    |  <------------   |    READY!    |
|              |                  |              |
 --------------                    --------------

Deploying

Once the Ready state has been confirmed, PLAYER 1 will deploy a smart contract to facilitate the Rock, Paper, Scissors game. While PLAYER 1 is deploying, PLAYER 2 is waiting for confirmation of the deployed smart contract. Once the smart contract is deployed, PLAYER 1 will send a confirmation message to PLAYER 2.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----
        ^                                   
        |                                   
 --------------                    --------------
|              |                  |              |
|              |                  |              |
|   PLAYER 1   |                  |   PLAYER 2   |
|   DEPLOYING  |                  |    WAITING   |
|              |                  |              |
 --------------                    --------------

Once PLAYER 1 gets confirmation from the blockchain that the smart contract is deployed...

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----


 --------------                    --------------
|              |     MESSAGE      |              |
|              |  ------------>   |              |
|   PLAYER 1   |                  |   PLAYER 2   |
|   DEPLOYED!  |                  |  NEXT STATE! |
|              |                  |              |
 --------------                    --------------

Submitting Answer

Once the contract is deployed and PLAYER 2 has confirmation of this, then both players submit their answers to the smart contract on the blockchain. The answers they submit are run through a caesar cipher to keep the answer secret to avoid cheating.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----
        ^                                ^
        |                                |
 --------------                    --------------
|              |                  |              |
|              |                  |              |
|   PLAYER 1   |                  |   PLAYER 2   |
|  SUBMITTING  |                  |  SUBMITTING  |
|              |                  |              |
 --------------                    --------------

Once each player gets a confirmation from the blockchain that their answer is submitted, they inform the other player that they have answered.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----


 --------------                    --------------
|              |     MESSAGE      |              |
|              |  ------------>   |              |
|   PLAYER 1   |     MESSAGE      |   PLAYER 2   |
|  SUBMITTED!  |  <------------   |  SUBMITTED!  |
|              |                  |              |
 --------------                    --------------

Confirming Submissions

Following the commitment scheme, each player now calls into the smart contract and ensures that the opponent has submitted an answer. Keep in mind, the only information they will find is an encoded answer, but it proves the other player has submitted their response. Once a player verifies their opponent has submitted an answer, they send them a message that they are ready to move on to the final state.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----
        ^                                ^
        |                                |
 --------------                    --------------
|              |                  |              |
|              |                  |              |
|   PLAYER 1   |                  |   PLAYER 2   |
|   CHECKING   |                  |   CHECKING   |
|  SUBMISSION  |                  |  SUBMISSION  |
 --------------                    --------------

Now that each player knows the opponent has submitted an encoded answer and thus cannot cheat...

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----


 --------------                    --------------
|              |     MESSAGE      |              |
|              |  ------------>   |              |
|   PLAYER 1   |     MESSAGE      |   PLAYER 2   |
|  CONFIRMED!  |  <------------   |  CONFIRMED!  |
|              |                  |              |
 --------------                    --------------

Reveal

Now that each player know that their opponent has submitted an answer, they are ready to exchange cipher keys. The keys are sent in a message between each player and then the answer submitted to the blockchain can be decoded. From there, each player uses their own logic to decide if they won, lost, or if the game was a draw.

BLOCKCHAIN
 -----        -----        -----        -----        -----
|     | ---> |     | ---> |     | ---> |     | ---> |     |
 -----        -----        -----        -----        -----


 --------------                    --------------
|              |  MESSAGE (KEY)   |              |
|              |  ------------>   |              |
|   PLAYER 1   |  MESSAGE (KEY)   |   PLAYER 2   |
|    WINNER!   |  <------------   |    LOSER!    |
|              |                  |              |
 --------------                    --------------

I hope you enjoyed playing! Thanks for looking at this demo and let me know if you have any question at [email protected].