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 directory | Source files |
|---|---|
components | 5 |
pages | 5 |
(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.
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);- Line 323
// const { blockhash } = await connection.getLatestBlockhash();: Fetches a recent blockhash. Transactions expire if it gets too old. - Line 328
// // Send transaction using the wallet's sendTransaction method: Submits the signed transaction to the cluster.
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);- Line 323
const { blockhash } = await connection.getLatestBlockhash();: Fetches a recent blockhash. Transactions expire if it gets too old. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run dev | next dev |
. | npm run start | next start |
. | npm run build | next build |
. | npm run lint | next lint && npx prettier --check "{__tests__,components,pages,styles}/**/*.{ts,tsx,js,jsx}" && npx tsc --noEmit |
What you could build from it
- Fork the SuperStack copy and extend it within the Gaming gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Compressed NFTs and state compression
- Learn the pattern first: Building and sending transactions from a client