Skip to content

IrfanSteps/2048-ink-l2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048 Leaderboard — Ink L2 Smart Contract

On-chain leaderboard for the 2048 game, deployed on Ink Sepolia (Ink L2 testnet).

Contract Overview

Leaderboard.sol tracks the best score ever achieved by each wallet and exposes a ranked top-10 view.

Function Description
submitScore(uint256 score) Records a new score; only updates storage if it beats the caller's personal best.
getTopScores() Returns the top 10 (address[], uint256[]) sorted by score descending.
playerCount() Total number of unique players on the board.
bestScore(address) Public mapping — query anyone's personal best.

Event: ScoreSubmitted(address indexed player, uint256 score) — emitted only when a new personal best is set.


Prerequisites

Tool Version
Foundry latest
Node / npm optional (for front-end integration only)

Install Foundry:

curl -L https://foundry.paradigm.xyz | bash
foundryup

Setup

# 1. Clone / open the project
cd 2048

# 2. Install dependencies
forge install

# 3. Copy the env template
cp .env.example .env
# Edit .env and set PRIVATE_KEY (and optionally RPC_URL)

Running Tests

forge test -vv

Run with gas reports:

forge test --gas-report

Run only a specific test:

forge test --match-test test_getTopScores_capsAtTen -vvv

Deploying to Ink Sepolia

Get test ETH: Use the Ink Sepolia faucet before deploying.

# Load env vars (PowerShell)
$env:PRIVATE_KEY = (Get-Content .env | Select-String "PRIVATE_KEY").ToString().Split("=")[1]

# Deploy + broadcast
forge script script/Deploy.s.sol \
  --rpc-url ink_sepolia \
  --private-key $env:PRIVATE_KEY \
  --broadcast

With Contract Verification

forge script script/Deploy.s.sol \
  --rpc-url ink_sepolia \
  --private-key $env:PRIVATE_KEY \
  --broadcast \
  --verify \
  --verifier-url https://explorer-sepolia.inkonchain.com/api \
  --verifier etherscan \
  --etherscan-api-key verifyContract

The foundry.toml pre-configures the ink_sepolia network alias so you don't need to type the full RPC URL.


Network Details

Property Value
Network Ink Sepolia
RPC URL https://rpc-gel-sepolia-ingress.inkonchain.com
Block Explorer https://explorer-sepolia.inkonchain.com
Chain ID 763373

Project Structure

2048/
├── src/
│   └── Leaderboard.sol       # Main contract
├── test/
│   └── Leaderboard.t.sol     # Forge tests (unit + fuzz)
├── script/
│   └── Deploy.s.sol          # Deployment script
├── lib/                      # Forge dependencies (forge-std etc.)
├── foundry.toml              # Foundry configuration
├── .env.example              # Environment variable template
└── README.md

License

MIT

About

2048 game on Ink L2 with on-chain leaderboard and daily check-in streak system

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors