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
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
, andscore
parameters are required to create a new player. Adjust accordingly if your contract implementation differs.
This content originally appeared on DEV Community and was authored by Dhokai Raj B
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.