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
- Allowing the players to play the game multiple times and keep a record of the games.
- Allowing the players to bet APT coins.
- A Bank to Store the Coins and give it to user after result.
- Allowing users to deposit the coins to bank (well, they won't get it back) so that the computer can bet the bank money.
- Admin only command (Allowed for everyone for testing purpose) to withdraw from the bank to their wallet.
- Emitting events to keep a record of games and transactions.
- 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.
- Home Page
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
-
⚠️ 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
- NodeJS and NPM
- Aptos CLI (Only if you want to make changes to the move module and republish it)
git clone https://github.com/AdNarayan07/Aptos-RockPaperScissors
cd Aptos-RockPaperScissors
npm install
npm run dev
Then visit http://localhost:5173/ to see and interact with the application.
If you want to check if admin only restrictions work, follow these steps:
- Navigate to module directory
cd module
- Initiate a new aptos testnet account
aptos init
- Go to
module/.aptos/config.yaml
file and copy account address. - Replace the owner addresses in
module/move.toml
andsrc/core/constants.ts
files with the new address. - Uncommentify the following codes at following locations:
- (Optional) Add your keyless account address with
0x
prefix in ADMINS insrc/core/constants.ts
, and here:
newadmin = "<YOUR_ADDRESS_WITHOUT 0x>"
module/sources/RockPaperScissors.move #L103
assert!( signer_address == @owner || signer_address == @adnarayan || signer_address == @newadmin, 403); // 403 unauthorized access
- Publish the module
aptos move publish
- 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)