Snack Game Build Better on Stellar: Smart Contract Challenge

This is a submission for the Build Better on Stellar: Smart Contract Challenge : Build a dApp

What I Built

SnackGame

Demo

My Code

Journey

Additional Prize Categories: Glorious Game and/or Super Sustainab…


This content originally appeared on DEV Community and was authored by Dhokai Raj B

This is a submission for the Build Better on Stellar: Smart Contract Challenge : Build a dApp

What I Built

SnackGame

Demo

Image description

My Code

Journey

Additional Prize Categories: Glorious Game and/or Super Sustainable
Here's how you can invoke the methods of the Stellar smart contract for the snake game using the soroban contract invoke command. Replace <DEPLOYED_CONTRACT_ADDRESS> with your actual deployed contract address.

1. Create a Player

soroban contract invoke --id CBGPKZU7CNVUITUZO5SJXMBIMVHZPU2PIOJAM7MBWBPEITKUY2YLEJRB --source alice --network testnet -- add_player --name "Alice" --public_key "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF" --score 100

2. Update a Player's Score

soroban contract invoke --id CBGPKZU7CNVUITUZO5SJXMBIMVHZPU2PIOJAM7MBWBPEITKUY2YLEJRB --source alice --network testnet -- update_player --player_id 1 --new_score 150

3. Get Player by ID

soroban contract invoke --id CBGPKZU7CNVUITUZO5SJXMBIMVHZPU2PIOJAM7MBWBPEITKUY2YLEJRB --source alice --network testnet -- get_player_by_id --player_id 1

4. Get All Players

soroban contract invoke --id CBGPKZU7CNVUITUZO5SJXMBIMVHZPU2PIOJAM7MBWBPEITKUY2YLEJRB --source alice --network testnet -- get_all_players

5. Delete a Player by ID

soroban contract invoke --id CBGPKZU7CNVUITUZO5SJXMBIMVHZPU2PIOJAM7MBWBPEITKUY2YLEJRB --source alice --network testnet -- delete_player --player_id 1

Notes:

  • Replace "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF" with a valid public key for your player.
  • The --id flag represents the ID of the player when updating, retrieving, or deleting specific player data.
  • The commands assume that the name, public_key, and score parameters are required to create a new player. Adjust accordingly if your contract implementation differs.

@chintanonweb


This content originally appeared on DEV Community and was authored by Dhokai Raj B


Print Share Comment Cite Upload Translate Updates
APA

Dhokai Raj B | Sciencx (2024-08-18T21:01:24+00:00) Snack Game Build Better on Stellar: Smart Contract Challenge. Retrieved from https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/

MLA
" » Snack Game Build Better on Stellar: Smart Contract Challenge." Dhokai Raj B | Sciencx - Sunday August 18, 2024, https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/
HARVARD
Dhokai Raj B | Sciencx Sunday August 18, 2024 » Snack Game Build Better on Stellar: Smart Contract Challenge., viewed ,<https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/>
VANCOUVER
Dhokai Raj B | Sciencx - » Snack Game Build Better on Stellar: Smart Contract Challenge. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/
CHICAGO
" » Snack Game Build Better on Stellar: Smart Contract Challenge." Dhokai Raj B | Sciencx - Accessed . https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/
IEEE
" » Snack Game Build Better on Stellar: Smart Contract Challenge." Dhokai Raj B | Sciencx [Online]. Available: https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/. [Accessed: ]
rf:citation
» Snack Game Build Better on Stellar: Smart Contract Challenge | Dhokai Raj B | Sciencx | https://www.scien.cx/2024/08/18/snack-game-build-better-on-stellar-smart-contract-challenge-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.