Sol.College

Full lesson

Candy-Blinks

Original
JohnPaulPabelico/Candy-Blinks
SuperStack fork
Blockchains/Candy-Blinks @ 88bf53d
Stars
1
Last push (original)
2024-10-22
Languages
TypeScript, CSS, Shell, JavaScript, Dockerfile
Detected stack
MetaplexNext.jsSolana Actionsweb3.js
Categories
NFTs & Digital Assets
Licence
Apache-2.0
Homepage
https://candy-mint.vercel.app

Architecture

165 source files. By extension: .tsx ×97, .ts ×66, .js ×2.

Top-level directorySource files
candyblinks56
dapp45
landing35
backend29

Dapp: deploying

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

JohnPaulPabelico/Candy-Blinks · candyblinks/app/blinks/mint/[handle]/route.ts L1–24 @ 88bf53d · Apache-2.0 · original
import {  ACTIONS_CORS_HEADERS,  ActionGetResponse,  ActionPostRequest,  ActionPostResponse,  createPostResponse,} from "@solana/actions";import { mintTransaction, getBlink } from "./utils";import client from "@/app/lib/blinksightsClient"; export const GET = async (  req: Request,  { params }: { params: { handle: string } }) => {  const handle = params.handle;   try {    console.log("fetching blink");    console.log(getBlink);    const blinksData = await getBlink(handle);     if (blinksData.length === 0) {      console.error("No blinks found for the given handle");      throw new Error("No blinks found for the given handle");
  1. Line 3 ActionGetResponse,: The metadata a Blink client renders (title, icon, buttons).
  2. Line 5 ActionPostResponse,: Returns the serialized transaction the wallet will sign.
JohnPaulPabelico/Candy-Blinks · candyblinks/app/blinks/mint/[handle]/tip/[amount]/spl-transfer.ts L1–23 @ 88bf53d · Apache-2.0 · original
import {  ComputeBudgetProgram,  Connection,  LAMPORTS_PER_SOL,  PublicKey,  SystemProgram,  Transaction,  TransactionMessage,  VersionedTransaction,  clusterApiUrl,} from "@solana/web3.js";import { ENDPOINT } from "../../utils";const {  TOKEN_2022_PROGRAM_ID,  TOKEN_PROGRAM_ID,} = require("@solana/spl-token");const splToken = require("@solana/spl-token"); type TransferSolTransactionParam = {  from: string;  amount: number;  // to: string};
  1. Line 2 ComputeBudgetProgram,: Sets the compute-unit limit or price (priority fee).
  2. Line 14 TOKEN_2022_PROGRAM_ID,: Targets the Token-2022 program instead of the original Token Program.

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
dappnpm run devnext dev
dappnpm run startnext start
dappnpm run buildnext build
dappnpm run lintnext lint
landingnpm run devnext dev
landingnpm run startnext start
landingnpm run buildnext build
landingnpm run lintnext lint
candyblinksnpm run devnext dev
candyblinksnpm run startnext start
candyblinksnpm run buildnext build
candyblinksnpm run lintnext lint
backendnpm run devyarn nodemon ./index.ts
backendnpm run buildyarn tsc
backendnpm run testyarn jest

What you could build from it

Used in lessons