Sol.College

Full lesson

EldoriaBattlestorm

What it does

From the project README:

Welcome to **Eldoria Battlestorm**, a turn-based strategy game built on the Solana blockchain! In this game, players engage in strategic battles using their unique characters to claim victory. The game leverages Solana's fast and secure blockchain to ensure a seamless and fair gaming experience.
Original
EldoriaGuild/EldoriaBattlestorm
SuperStack fork
Blockchains/EldoriaBattlestorm @ f56a784
Stars
0
Last push (original)
2024-10-12
Languages
Rust, TypeScript, Python, Dockerfile, Shell
Detected stack
MetaplexNative Rustweb3.js
Categories
Other
Licence
MIT

Architecture

16 source files. By extension: .ts ×9, .rs ×6, .py ×1.

Top-level directorySource files
solana_nft8
eldoria_battlestorm_main6
echoes_of_eldoria_api1
client1

Dapp: deploying

This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/eldoriabattlestorm/, once it is deployed and checked on devnet. Until then, run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

EldoriaGuild/EldoriaBattlestorm · client/main.ts L109–132 @ f56a784 · MIT · original
     const ix = new TransactionInstruction({        programId:programId,        keys:[          {isSigner:false,isWritable:true,pubkey:nft},        ],        data:Buffer.from([1])});                const message = new TransactionMessage({          instructions: [ix],            payerKey: payer.publicKey,            recentBlockhash : (await connection.getLatestBlockhash()).blockhash          }).compileToV0Message();                const tx = new VersionedTransaction(message);          tx.sign([payer]);            const sig = await connection.sendTransaction(tx); }const burn_nft_pda = async () => {        const burn = PublicKey.findProgramAddressSync([Buffer.from("burn")],programId)
  1. Line 121 recentBlockhash : (await connection.getLatestBlockhash()).blockhash: Fetches a recent blockhash. Transactions expire if it gets too old.
  2. Line 127 const sig = await connection.sendTransaction(tx);: Submits the signed transaction to the cluster.
  3. Line 132 const burn = PublicKey.findProgramAddressSync([Buffer.from("burn")],programId): Derives a PDA from seeds and the program ID and returns the address with its canonical bump.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
eldoria_battlestorm_mainnpm run startts-node client/main.ts
solana_nftnpm run startnodemon --exec ts-node src/server.ts
solana_nftnpm run buildtsc
solana_nftnpm run testecho "Error: no test specified" && exit 1

What you could build from it