Monad
@monad-xyz
Your onchain game doesn’t need to be slow We built Monad2048 - a fully onchain version of 2048 - to show how to build fast and button-mashable gameplay while keeping all game logic on chain If you're building responsive, high-throughput dapps, this thread is your blueprint 🧵
179 replies
538 recasts
1531 reactions
Monad
@monad-xyz
Monad2048 runs entirely onchain: every move is a transaction and is validated by a smart contract. No servers involved. Play the game at 2048.monad.xyz and read about the build process at https://blog.monad.xyz/blog/build-2048
18 replies
62 recasts
253 reactions
Monad
@monad-xyz
We aimed to prevent cheating while keeping moves instant. A deterministic seed generates new tiles, discouraging cheating without slowing gameplay. Here’s how we designed it. Contracts: https://github.com/monad-developers/2048-contracts
1 reply
3 recasts
38 reactions
Monad
@monad-xyz
The Monad2048 contract stores the 4x4 board in one uint256. Each tile’s value is encoded in 8 bits. This function reads a tile’s value:
1 reply
2 recasts
33 reactions
Monad
@monad-xyz
Gameplay works in two steps: 1. startGame: Submit four initial boards to begin, and a seed. 2. play: Submit a move and the resultant board. The seed is used in a deterministic formula to determine where new tiles spawn upon new moves.
1 reply
2 recasts
24 reactions
Monad
@monad-xyz
The frontend uses Privy for creating player wallets, which avoids repeated popup confirmation for each move. We update the interface instantly after a move, sending transactions in the background. If a transaction fails, we revert to the last valid board.
1 reply
1 recast
18 reactions
Monad
@monad-xyz
For rapid transactions, we manage nonce locally and avoid unnecessary RPC calls (e.g. in simulations). Transactions are signed with viem but sent directly to the RPC. This prevents large delays between client and chain state. To skip simulations safely, test client transaction inputs beforehand.
1 reply
2 recasts
18 reactions