Sol.College

Full lesson

Gamebytes-Radar

Privy Testing

What it does

From the project README:

This is a template for integrating **Privy Auth** into a NextJS project. Check out the deployed app here!
Original
elisading/Gamebytes-Radar
SuperStack fork
Blockchains/Gamebytes-Radar @ 934fe07
Stars
0
Last push (original)
2024-10-26
Languages
TypeScript, JavaScript, CSS
Detected stack
Next.js
Categories
Gaming
Licence
MIT
Homepage
https://privy-next-app.vercel.app

Architecture

14 source files. By extension: .tsx ×8, .js ×3, .ts ×3.

Top-level directorySource files
components5
pages5
(root)4

Dapp: deploying

This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/gamebytes-radar/, 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.

elisading/Gamebytes-Radar · pages/privytest.ts L313–336 @ 934fe07 · MIT · original
 //       // Build a transaction to send 0.01 SOL to the recipient address//       const transaction = new Transaction().add(//         SystemProgram.transfer({//           fromPubkey: walletPublicKey,//           toPubkey: testPubkey,//           lamports: 10000000, // 0.01 SOL (1 SOL = 1,000,000,000 lamports)//         })//       ); //       const { blockhash } = await connection.getLatestBlockhash();//       transaction.recentBlockhash = blockhash;//       transaction.feePayer = walletPublicKey;//       console.log("Transaction object:", transaction); //       // Send transaction using the wallet's sendTransaction method//       const txHash = await currentWallet?.sendTransaction!(transaction, connection); //       sendUserEvent({eventType: "deposit", data: JSON.stringify({tx: txHash})});//       // Log and display the transaction result//       console.log("Transaction sent, hash:", txHash);  //       setTransactionResult(txHash);
  1. Line 323 // const { blockhash } = await connection.getLatestBlockhash();: Fetches a recent blockhash. Transactions expire if it gets too old.
  2. Line 328 // // Send transaction using the wallet's sendTransaction method: Submits the signed transaction to the cluster.
elisading/Gamebytes-Radar · pages/dashboard.tsx L313–336 @ 934fe07 · MIT · original
       // Build a transaction to send 0.01 SOL to the recipient address      const transaction = new Transaction().add(        SystemProgram.transfer({          fromPubkey: walletPublicKey,          toPubkey: testPubkey,          lamports: 10000000, // 0.01 SOL (1 SOL = 1,000,000,000 lamports)        })      );       const { blockhash } = await connection.getLatestBlockhash();      transaction.recentBlockhash = blockhash;      transaction.feePayer = walletPublicKey;      console.log("Transaction object:", transaction);       // Send transaction using the wallet's sendTransaction method      const txHash = await currentWallet?.sendTransaction!(transaction, connection);       sendUserEvent({eventType: "deposit", data: JSON.stringify({tx: txHash})});      // Log and display the transaction result      console.log("Transaction sent, hash:", txHash);        setTransactionResult(txHash);
  1. Line 323 const { blockhash } = await connection.getLatestBlockhash();: Fetches a recent blockhash. Transactions expire if it gets too old.
  2. Line 328 // Send transaction using the wallet's sendTransaction method: Submits the signed transaction to the cluster.

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
.npm run devnext dev
.npm run startnext start
.npm run buildnext build
.npm run lintnext lint && npx prettier --check "{__tests__,components,pages,styles}/**/*.{ts,tsx,js,jsx}" && npx tsc --noEmit

What you could build from it