Giter VIP home page Giter VIP logo

sui8192's Introduction

SUI 8192

A fully on-chain, extra challenging version of the popular 2048 game. Built on Sui by Ethos.

You can play SUI 8192 at https://ethoswallet.github.io/Sui8192

SUI 8192 consists of a smart contract that allows the player to mint a game that is playable on chain.

The front-end submits transaction to the Sui blockchain that calculates the next state of the game board. That next state is returned to the front end to display the next state. Most of the logic in the front-end involves diffing and animating the game board states to create an interesting and enjoyable user experience.

Sui

This project is built on the Sui blockchain, which provides the performance necessary for a great game experience. Every move is a transaction that is recorded on-chain, making the gameplay verifiable, shareable, and transferable. Each game is an NFT that can be sent to anyone and will display in a web3 wallet (such as the Ethos Wallet).

Ethos

This project uses the Ethos APIs to make the SUI 8192 game accessible to people who do not yet have a web3 wallet. It allows them to start playing the game right away without having to figure out a wallet first.

As far as the game is concerned every player has a wallet because the Ethos APIs provide a unified interface for both players with and without wallets.

The primary methods that this game uses to do this are:

<EthosConnectProvider>, SignInButton, and ethos.transact()

Each of these can be found by searching in js/game.js

  • The Ethos APIs currently require react and react-dom which is why they are included.

The Smart Contract

The SUI 8192 smart contract is written Sui Move for deployment on the Sui blockchain. It consists of three parts:

  1. Game: Primarily entry functions for making moves and recording the overall game state.

  2. Game Board: Most of the game logic.

  3. Leaderboard: A shared object that accepts games, sorting them into order based on top tile and score.

The code for the smart contract is in the "move" folder.

If you deploy the smart contract and want to use the new deployment in the game you'll need to edit js/constants.js and set the contract address and leaderboard address.

You wil see output like this:

Created Objects:
  - ID: 0x6d86e967767b3d736447bc5f29c74e8b6b9c5dd7 , Owner: Immutable
  - ID: 0xf9803ad429fe9083a6c26f52c4f1ffa981d5ccbf , Owner: Shared

The immutable object is the contract address and the shared object is the leaderboard address.

Working With The Smart Contract

From the move folder:

Build Contract

sui move build

Test Contract

sui move test

or

sui move test --filter SUBSTRING

Deploy Contract

sui client publish --gas-budget 10000

You will need to update the contract and leaderboard address in constants.ts with the values provided when you publish the contract.

The Front-End

The front end is written in plain javascript, html, and css. It has minimal dependencies and is statically hosted on GitHub, using the blockchain for all persistent state.

It has react as a dependency to work properly with the Ethos apis which provide wallet connecting capabilities as well as an easy pathway for people who do not yet have a wallet to play the game via email or social authentication.

Working With The Front-End

Initialize Front End

yarn

Running Front End

yarn start

This should automatically open a browser window with the latest code running.

Deploy Front End

Running yarn start will generate the necessary static files for deployment. Simply commit those files to the main branch of github and the live site should be updated.

sui8192's People

Contributors

adamwade2384 avatar i-am-neon avatar jaredcosulich avatar jayrodkc avatar juzybits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sui8192's Issues

error Sui8192

Hello, the game freezes and after refreshing the page it does not save as it was on devnet
лллшэтос
0x9ef17cc644ccd0ee599ad7204b3588dc4bad7c15

can't upload highscore

can't upload highscore and paid gas fees multiple times

32000 would look nice on the board!

I can't run 8192 in my local

Env: Windows10
use: yarn && yarn build && npx browser-sync start --server

Error: Can't walk dependency graph: Cannot find module 'C:\Users\zhou\Desktop\Sui\code\Sui8192\js\*' from 'C:\Users\zhou\Desktop\Sui\code\Sui8192\js\_fake.js'
    required by C:\Users\zhou\Desktop\Sui\code\Sui8192\js\_fake.js
    at C:\Users\zhou\Desktop\Sui\code\Sui8192\node_modules\resolve\lib\async.js:167:35
    at load (C:\Users\zhou\Desktop\Sui\code\Sui8192\node_modules\resolve\lib\async.js:186:43)
    at onex (C:\Users\zhou\Desktop\Sui\code\Sui8192\node_modules\resolve\lib\async.js:211:17)
    at C:\Users\zhou\Desktop\Sui\code\Sui8192\node_modules\resolve\lib\async.js:24:69
    at FSReqCallback.oncomplete (node:fs:198:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Not able to play

Not able to play, constantly receive this error on wallet connect:

Error: Transaction failed with the following error. Error executing transaction with request type: Error: RPC Error: The response returned from RPC server does not match the TypeScript definition. This is likely because the SDK version is not compatible with the RPC server. Please update your SDK version to the latest. Result received was: {"certificate":{"transactionDigest":"9QxFkMMtukbJCtJMaZYpjSSuZKQbZTdPoorjLY27461G","data":{"transactions":[{"Call":{"package":"0x60024563e331cde585fe9dca02a33b088bda9f5c","module":"game_8192","function":"create"}}],"sender":"0x2d9cac262b60766086a8d5ad997f6b5408d99864","gasData":{"payment":{"objectId":"0x03819e551af118f06760ee1d2e610c8b82498df2","version":2543470,"digest":"fbaj2R9iJm5in9sKszC0Tnfx0zxt5Lw/LWvtbkplo1c="},"owner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864","price":1,"budget":10000}},"txSignatures":["ABqOGDmnAd9tI+r1aAsdsk4ufYxsnCkLeGaQt/EN2p8bvnUwtUE6xoRtQEcriEHE+HgNFIk2wwlWEWzW/VcyDgVEc79Iw9HBzzIanRspiXTPHphUxzWK7lfhOSK5eKxQbQ=="],"authSignInfo":{"epoch":388,"signature":"pcv4XUe0x1n97dzC770sVyMSjGmDP5TIqK10SR/tQa1aDYYSQzJX/l8Wo3bXTyrd","signers_map":[58,48,0,0,1,0,0,0,0,0,2,0,16,0,0,0,1,0,2,0,3,0]}},"effects":{"transactionEffectsDigest":"6r9vaBDJMoG2P8cxPGDvVZu9wUcj3hz4oALQZo2KXpoZ","effects":{"status":{"status":"success"},"executedEpoch":388,"gasUsed":{"computationCost":843,"storageCost":91,"storageRebate":16},"transactionDigest":"9QxFkMMtukbJCtJMaZYpjSSuZKQbZTdPoorjLY27461G","created":[{"owner":{"AddressOwner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864"},"reference":{"objectId":"0x5b9ac03244df7f5f9a0ce81d3ea3a3831ecfc106","version":2543471,"digest":"dqmdA3glWazallhp5eu/6tpKEwoXKgPdVZhk6ZDunIU="}},{"owner":{"ObjectOwner":"0x884f5bea8380c679e70c2b7dcffade0bdcbe56d9"},"reference":{"objectId":"0x6d2060d29bad199b6d6c0bc2ebe43b91355bdc66","version":2543471,"digest":"JjyKaFWjL/8hK5BLLCPA1UrjPBEmDtfR27+pA5vmGxk="}}],"mutated":[{"owner":{"AddressOwner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864"},"reference":{"objectId":"0x03819e551af118f06760ee1d2e610c8b82498df2","version":2543471,"digest":"hUaeb2omWLby/v/b/g2p+Af5HHvudsSFY7tRBhkgtbY="}}],"gasObject":{"owner":{"AddressOwner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864"},"reference":{"objectId":"0x03819e551af118f06760ee1d2e610c8b82498df2","version":2543471,"digest":"hUaeb2omWLby/v/b/g2p+Af5HHvudsSFY7tRBhkgtbY="}},"events":[{"coinBalanceChange":{"packageId":"0x0000000000000000000000000000000000000002","transactionModule":"gas","sender":"0x2d9cac262b60766086a8d5ad997f6b5408d99864","changeType":"Gas","owner":{"AddressOwner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864"},"coinType":"0x2::sui::SUI","coinObjectId":"0x03819e551af118f06760ee1d2e610c8b82498df2","version":2543470,"amount":-918}},{"newObject":{"packageId":"0x60024563e331cde585fe9dca02a33b088bda9f5c","transactionModule":"game_8192","sender":"0x2d9cac262b60766086a8d5ad997f6b5408d99864","recipient":{"AddressOwner":"0x2d9cac262b60766086a8d5ad997f6b5408d99864"},"objectType":"0x60024563e331cde585fe9dca02a33b088bda9f5c::game_8192::Game8192","objectId":"0x5b9ac03244df7f5f9a0ce81d3ea3a3831ecfc106","version":2543471}},{"newObject":{"packageId":"0x60024563e331cde585fe9dca02a33b088bda9f5c","transactionModule":"game_8192","sender":"0x2d9cac262b60766086a8d5ad997f6b5408d99864","recipient":{"ObjectOwner":"0x884f5bea8380c679e70c2b7dcffade0bdcbe56d9"},"objectType":"0x2::dynamic_field::Field

Wallet id:
0x2d9cac262b60766086a8d5ad997f6b5408d99864

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.