Skip to content

AdNarayan07/Aptos-RockPaperScissors

Repository files navigation

Aptos: Rock Paper Scissors

Overview

This project focuses on upgrading the Aptos Rock Paper Scissors Game in StackUp x Move on Aptos Quest 3 which used Aptos Randomness API to generate a random computer move, enabling the users to play with computer.

Check out the application 👉 https://adnarayan-rock-paper-scissors.netlify.app

Additional Features


  • Frontend to interact with the module using Aptos Keyless Signing, built on Aptos Keyless Example repository from Aptos Labs.
    • Home Page
      • Showing the profile, address and wallet balance of currently logged in user and amount of APT in game bank.
      • Playing the game, and making APT bets (optional)
      • Fetching and displaying user's previous games.
    • Admin Page
      • Forms to deposit and withdraw coins to and from the game bank.
      • A list of all the events emitted, paginated, linking them to corresponding transactions in aptos explorer.

Tries to fund the user wallet from faucet automatically if a new account is created or the user runs low on balance. See below for troubleshooting


Troubleshooting

  • ⚠️ Please fund your wallet with APT token if you get "Account Not Found" or "Insufficient Balance" or "Faucet Error".

  • ⚠️ If you bet the amount which is very close to your current wallet balance, the result declaration might fail and you will get a "INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE" error with "Result Undeclared" warning, in such case fund your wallet with APT token and play a new game. This will declare the previously undeclared game results.

  • ⚠️ If you get "INVALID_SIGNATURE" error, clear the site data and then relogin.

    Aptos API Error Solution
    404 Transaction Not Found Try Later
    500 Internal Server Error Clear Site Data and Relogin

Running the Project Locally

Prerequisites

  1. NodeJS and NPM
  2. Aptos CLI (Only if you want to make changes to the move module and republish it)

Setting Up Project

git clone https://github.com/AdNarayan07/Aptos-RockPaperScissors
cd Aptos-RockPaperScissors
npm install

Running the Project

npm run dev

Then visit http://localhost:5173/ to see and interact with the application.
⚠️ Don't change the port number on your own or the Google OAuth2 won't work!

Checking the Restrictions for Admin Only Functions:

If you want to check if admin only restrictions work, follow these steps:

  1. Navigate to module directory
cd module
  1. Initiate a new aptos testnet account
aptos init
  1. Go to module/.aptos/config.yaml file and copy account address.
  2. Replace the owner addresses in module/move.toml and src/core/constants.ts files with the new address.
  3. Uncommentify the following codes at following locations:
  4. (Optional) Add your keyless account address with 0x prefix in ADMINS in src/core/constants.ts, and here:

module/move.toml #L9

newadmin = "<YOUR_ADDRESS_WITHOUT 0x>"

module/sources/RockPaperScissors.move #L103

assert!( signer_address == @owner || signer_address == @adnarayan || signer_address == @newadmin, 403); // 403 unauthorized access
  1. Publish the module
aptos move publish
  1. Run the frontend again. Now you won't have access to admin page and admin commands (if your account address is not included in admins)

Video Demos

Logging in and Playing the Game

Login.and.Play.mp4

Funding your Wallet from the Faucet

Getting.funds.from.faucet.mp4

Clearing Site Data (in Chrome)

Clearing.site.data.chrome.mp4

Admin Page

Admin.Controls.1.mp4

About

A Rock Paper Scissors game with Betting function developed in Move language on Aptos

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages