Sol.College

Full lesson

solana_swap

What it does

From the project README:

Welcome to the Solana Swap App! This application allows users to connect their wallets and trade between different cryptocurrencies on the Solana blockchain.
Original
keldan24/solana_swap
SuperStack fork
Blockchains/solana_swap @ 415f191
Stars
0
Last push (original)
2024-10-08
Languages
TypeScript, CSS, JavaScript
Detected stack
Next.jsSolana Actionsweb3.js
Categories
DeFi
Licence
MIT
Homepage
https://solana-swap-nu.vercel.app

Architecture

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

Top-level directorySource files
app7
(root)1

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/solana-swap/. Until then, the lesson and step-by-step guide below are complete, and you can 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.

keldan24/solana_swap · app/api/actions/transfer-sol/route.ts L1–24 @ 415f191 · MIT · original
import { ActionGetResponse, ActionPostRequest, ActionPostResponse, ACTIONS_CORS_HEADERS} from "@solana/actions"import { clusterApiUrl, Connection } from "@solana/web3.js";import { SystemProgram } from "@solana/web3.js";import { Transaction, PublicKey } from "@solana/web3.js"; export async function GET(request: Request) {      const responseBody : ActionGetResponse = {    icon: "https://res.cloudinary.com/dek4edhda/image/upload/v1728419177/Asset_10Asset_utknt1.png",    description: " Help us to support solana blockchain",    title: "Donate",    label: " Hit me! ",    // error: {    //   message: "Blinks not fully implemented",    // },    // type: "action",  }    const response = Response.json(responseBody, {headers: ACTIONS_CORS_HEADERS});   return response}  export async function POST(request: Request) {       const requestBody: ActionPostRequest  = await request.json();
  1. Line 1 import { ActionGetResponse, ActionPostRequest, ActionPostResponse, ACTIONS_CORS_HEADERS} f: The metadata a Blink client renders (title, icon, buttons).
  2. Line 1 import { ActionGetResponse, ActionPostRequest, ActionPostResponse, ACTIONS_CORS_HEADERS} f: Returns the serialized transaction the wallet will sign.

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

What you could build from it

Used in lessons