Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tablelandnetwork/example-game-state-polygon
A simple multiplayer game example where the game state is stored on Tableland and a dynamic NFT is rendered from that data.
https://github.com/tablelandnetwork/example-game-state-polygon
games ipfs nfts sqlite tableland
Last synced: about 2 months ago
JSON representation
A simple multiplayer game example where the game state is stored on Tableland and a dynamic NFT is rendered from that data.
- Host: GitHub
- URL: https://github.com/tablelandnetwork/example-game-state-polygon
- Owner: tablelandnetwork
- License: unlicense
- Created: 2022-12-15T21:23:50.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-14T23:04:01.000Z (almost 2 years ago)
- Last Synced: 2024-08-21T10:19:16.299Z (6 months ago)
- Topics: games, ipfs, nfts, sqlite, tableland
- Language: Solidity
- Homepage: https://testnets.opensea.io/collection/tableland-game-state-example-v2
- Size: 35.2 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Game state management - a game of hangman
This is a game of hangman. A user can mint a new game using `safeMint` just like any NFT. Other players can play the NFT using `guessLetter` by submitting a target tokenID and their letter guess.
All game state and updates are shipped off to a table on Tableland.
The NFT is built on IFPS and reads that state to render the live game.
You could also easily build a dapp for viewing leaderboards, open games, etc.
## Gameplay
A user calls `safeMint(addr, "secret"). That user (addr) now owns an NFT for the game, awaiting people to guess "secret".
A player can now call `guessLetter(tokenId, "x"). Because "x" is not in "secret" one fail will be recorded. If 6 fails are recorded, the game ends and the NFT transfers back to the smart contract. If all the letters of the word of guessed before the game is over, the person submitting the final letter will get the winning NFT.
The state at each level is pushed to Tableland for rendering, query, search, etc.
## Example deployment (how to play)
https://mumbai.polygonscan.com/address/0xb5fa5f64f811df209ef7cc431575870860b29cfb#writeProxyContract
Use `safeMint` and `guessLetter` above to play.
## Example game state table on Tableland (how to view state)
https://testnets.opensea.io/assets/mumbai/0x4b48841d4b32c4650e4abc117a03fe8b51f38f68/4448
You can view the full state of the example deployments below running in the above table.
You can query that state here,
https://testnet.tableland.network/query?s=select%20*%20from%20game_store_80001_4448%20limit%201
## Example NFT (how to visually see the game and game nfts)
https://testnets.opensea.io/collection/tableland-game-state-example-v2
You can see multiple examples of open and completed games. Chose any open ones (white background) to make your own guesses.
View the React app in the /nft folder.
## Develop
You must have a `.env` file with the following information
```
PRIVATE_KEY={your wallet key with a balance of matic}
POLYGONSCAN_API_KEY={your polyscan api key for pushing the abi}
POLYGON_MUMBAI_API_KEY={your alchemy api key for mumbai}
REPORT_GAS=true
```### Install
`npm install`
### Start Tableland locally
`npm run tableland`
### Deploy to local hardhat
`npm run local` or upgrade `npm run localup`
### Deploy to Mumbai
`npm run deploy`
### Update
`npm run update`
## Develop the NFT
`cd nft`
`npm install`
`npm run start`
# Warning
This example is not maintained.