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 directory | Source files |
|---|---|
app | 7 |
(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.
app/api/actions/transfer-sol/route.ts L1–24 @ 415f191 · MIT · originalimport { 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();- Line 1
import { ActionGetResponse, ActionPostRequest, ActionPostResponse, ACTIONS_CORS_HEADERS} f: The metadata a Blink client renders (title, icon, buttons). - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run dev | next dev |
. | npm run start | next start |
. | npm run build | next build |
. | npm run lint | next lint |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)
- Learn the pattern first: SPL Tokens: mints, accounts and transfers