Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added +15
Empty file.
Empty file added +18
Empty file.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense para saber los atributos posibles.
// Mantenga el puntero para ver las descripciones de los existentes atributos.
// Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Iniciar Chrome para localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,19 @@ En dado caso de que no tengas las extensiones instaladas te aparecerá la siguie

Una vez empezado el proceso esperar a que termine. Puede tomar un tiempo debido a que se instalan todas las dependencias similar a la instalación en codespaces.

>ℹ️ Docuemntación oficial: https://solana.com/developers/templates/react-vite-anchor
>ℹ️ Docuemntación oficial: https://solana.com/developers/templates/react-vite-anchor

TERMINAL 1
cd /workspaces/Solana-Hackathon-Template-FullStack/template_codespaces

npm install

TERMINAL 2
cd /workspaces/Solana-Hackathon-Template-FullStack/template_codespaces/anchor

NO_DNA=1 anchor test

TERMINAL 1 de vuelta
npm run dev

Meterse al localhost que te de
1 change: 1 addition & 0 deletions SOlana-Hackathon-Template-FullStack
Submodule SOlana-Hackathon-Template-FullStack added at e8dd28
Empty file modified local-setup.sh
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions template_codespaces/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Dependencies
node_modules

# Build
dist
dist-ssr
*.local

# Editor
.vscode/*
!.vscode/extensions.json
.idea

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# OS
.DS_Store

# Anchor build artifacts
/anchor/.anchor/
/anchor/target/
4 changes: 4 additions & 0 deletions template_codespaces/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
pnpm-lock.yaml
src/generated
6 changes: 6 additions & 0 deletions template_codespaces/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
142 changes: 142 additions & 0 deletions template_codespaces/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Solana Hackathon con WayLearn

Solana es una blockchain de capa 1, orientada al alto rendimiento. Este repositorio es una plantilla full-stack (Anchor + React + Vite) con soporte ya configurado para comenzar tu proyecto de innovación social.

## Proyecto: Eco-Recaudación de Puntos con Basura Inteligente (WayLearn)

Objetivo: recolectar residuos y gamificar la limpieza urbana usando Solana para emitir recompensas tokenizadas basadas en el peso de cada desecho.

Características principales:
- Detección de tipo de basura con IA (Python/ML).
- Botes con sensor y báscula que generan un ticket o QR temporal por entrega.
- PDAs en Solana para cuentas de usuario y balances de puntos.
- Transacciones on-chain para registrar peso y emitir tokens SPL como recompensas.
- Frontend en React + Solana Wallet (Phantom) para consultar saldo de tokens y reclamar beneficios.

### Flujo ideal

1. Usuario escanea QR del bote.
2. Bote autentica y crea token temporal con meta (peso, tipo).
3. Al depositar, modelo IA valida y calcula puntos.
4. Se llama a un programa Anchor para incrementar el balance del usuario en la blockchain y mintear tokens SPL.
5. Usuario puede canjear tokens en la app o transferirlos.

## Getting Started

React + Vite starter with Tailwind CSS, `@solana/react-hooks`, and an Anchor vault program example.

## Getting Started

```shell
npx -y create-solana-dapp@latest -t solana-foundation/templates/kit/template_codespaces
```

```shell
npm install # Builds program and generates client automatically
npm run dev
```

Open [http://localhost:5173](http://localhost:5173), connect your wallet, and interact with the vault on devnet.

## What's Included

- **Wallet connection** via `@solana/react-hooks` with auto-discovery
- **WayLearn Token Program** - initialize mint, user profiles, record drops with token rewards
- **SOL Vault program** - deposit and withdraw SOL from a personal PDA vault
- **Codama-generated client** - type-safe program interactions using `@solana/kit`
- **Tailwind CSS v4** with light/dark mode

## Stack

| Layer | Technology |
| -------------- | --------------------------------------- |
| Frontend | React 19, Vite, TypeScript |
| Styling | Tailwind CSS v4 |
| Solana Client | `@solana/client`, `@solana/react-hooks` |
| Program Client | Codama-generated, `@solana/kit` |
| Program | Anchor (Rust) |

## Project Structure

```
├── src/
│ ├── App.tsx # Main app with wallet UI
│ ├── VaultCard.tsx # Vault deposit/withdraw UI
│ ├── providers.tsx # Solana client setup
│ ├── generated/vault/ # Codama-generated program client
│ └── main.tsx # Entry point
├── anchor/ # Anchor workspace
│ └── programs/vault/ # Vault program (Rust)
└── codama.json # Codama client generation config
```

## Deploy Your Own Vault

The included vault program is already deployed to devnet. To deploy your own:

### Prerequisites

- [Rust](https://rustup.rs/)
- [Solana CLI](https://solana.com/docs/intro/installation)
- [Anchor](https://www.anchor-lang.com/docs/installation)

### Steps

1. **Configure Solana CLI for devnet**

```bash
solana config set --url devnet
```

2. **Create a wallet (if needed) and fund it**

```bash
solana-keygen new
solana airdrop 2
```

3. **Build and deploy the program**

```bash
cd anchor
anchor build
anchor keys sync # Updates program ID in source
anchor build # Rebuild with new ID
anchor deploy
cd ..
```

4. **Regenerate the client and restart**
```bash
npm run setup # Rebuilds program and regenerates client
npm run dev
```

## Testing

Tests use [LiteSVM](https://github.com/LiteSVM/litesvm), a fast lightweight Solana VM for testing.

```bash
npm run anchor-build # Build the program first
npm run anchor-test # Run tests
```

The tests are in `anchor/programs/vault/src/tests.rs` and automatically use the program ID from `declare_id!`.

## Regenerating the Client

If you modify the program, regenerate the TypeScript client:

```bash
npm run setup # Or: npm run anchor-build && npm run codama:js
```

This uses [Codama](https://github.com/codama-idl/codama) to generate a type-safe client from the Anchor IDL.

## Learn More

- [Solana Docs](https://solana.com/docs) - core concepts and guides
- [Anchor Docs](https://www.anchor-lang.com/docs) - program development framework
- [Deploying Programs](https://solana.com/docs/programs/deploying) - deployment guide
- [framework-kit](https://github.com/solana-foundation/framework-kit) - the React hooks used here
- [Codama](https://github.com/codama-idl/codama) - client generation from IDL
18 changes: 18 additions & 0 deletions template_codespaces/anchor/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[toolchain]

[features]
resolution = true
skip-lint = false

[programs.devnet]
vault = "3Q7SQubHBDNhgdYZPvD1RtDCymvWdbmkVwVRp2zApAzz"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "cargo test"
Loading