Skip to content

P03 E-Commerce Blockchain (EuroToken + Stripe + 4 apps)#2

Open
MarkFrFn wants to merge 10 commits intomainfrom
practica-03-ecommerce
Open

P03 E-Commerce Blockchain (EuroToken + Stripe + 4 apps)#2
MarkFrFn wants to merge 10 commits intomainfrom
practica-03-ecommerce

Conversation

@MarkFrFn
Copy link
Collaborator

P03 — E-Commerce Blockchain con EuroToken + Stripe

Contratos inteligentes (Foundry + Solidity 0.8.24)

  • EuroToken — ERC20 mintable (6 decimales), stablecoin respaldada por Stripe
  • CompanyRegistry — registro de empresas en blockchain
  • ProductCatalog — catálogo de productos con control de stock on-chain
  • ShoppingCart — carrito persistente en contrato
  • InvoiceSystem — facturas inmutables creadas al hacer checkout
  • PaymentGateway — ejecuta transferFrom ERC20 y marca facturas como pagadas
  • EcommerceMain — punto de entrada único que expone todas las direcciones

Apps web (Next.js 15 + ethers.js v6 + Tailwind)

Puerto App Función
:6001 compra-stablecoin Compra EURT con tarjeta Stripe → webhook → mint on-chain
:6002 pasarela-de-pago approve + processPayment con MetaMask
:6003 web-admin Registro de empresa, gestión de productos, facturas
:6004 web-customer Catálogo, carrito, checkout, historial de pedidos

Flujo completo verificado

  1. Admin registra empresa y sube productos en :6003
  2. Cliente compra EURT con Stripe en :6001 → webhook mintea tokens on-chain
  3. Cliente añade productos al carrito en :6004 → checkout crea factura en blockchain
  4. Pasarela :6002 ejecuta ERC20.approve + processPayment → tokens transferidos al merchant
  5. Admin ve factura pagada y stock actualizado en :6003

Arrancar el proyecto

cd P03-ecommerce
bash restart-all.sh

MarkFrFn and others added 10 commits February 19, 2026 00:06
dApp completa para almacenar y verificar autenticidad de documentos
en blockchain Ethereum mediante firmas digitales ECDSA.

Stack: Solidity 0.8.18 · Foundry · OpenZeppelin ECDSA ·
       Next.js 14 · TypeScript · ethers.js v6 · Tailwind CSS

Incluye:
- Smart contract optimizado (sin bool exists, modifiers, optimizer)
- 11/11 tests pasando con script de visualizacion detallada
- Frontend con dark mode, drag & drop, CSV export, busqueda
- Script start.sh para arrancar todo el stack en un comando
- Documentacion completa: README, lecciones aprendidas, guion video
- Submodulos: OpenZeppelin contracts + forge-std

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename practica-01-eth-document-registry → P01-eth-document-registry
  and fix all submodule references (.gitmodules, .git/config, worktrees)
- Add P02-dao: DAO Voting Gasless with MinimalForwarder (ERC-2771),
  Next.js frontend, meta-tx relay, gasless voting with nonce fix
- Add docs for P01 and P02: GUIA_DE_USO, GUION_VIDEO, EJERCICIO_MULTI_VOTANTE
- Add root .gitignore, CLAUDE.md, docs/LECCIONES_APRENDIDAS.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Complete the rename: delete tracked files at old path after
P01-eth-document-registry/ rename was committed in previous commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- P01-eth-document-registry: smart contract + Next.js dapp (complete)
- P02-dao: DAO Voting Gasless with ERC-2771 meta-transactions (complete)
- Root: .gitignore, CLAUDE.md, docs/LECCIONES_APRENDIDAS.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Smart contracts (46 tests, 0 failed):
- stablecoin/sc: EuroToken ERC20, 6 decimals, mint by owner (19 tests)
- sc-ecommerce: CompanyRegistry, ProductCatalog, ShoppingCart,
  InvoiceSystem, PaymentGateway, EcommerceMain (27 integration tests)

Web apps (Next.js 15 + ethers v6 + Tailwind v4):
- compra-stablecoin :6001 — buy EURT with Stripe card + webhook mint
- pasarela-de-pago  :6002 — pay invoices with EURT (approve + processPayment)
- web-admin         :6003 — company dashboard, products, invoices
- web-customer      :6004 — catalog, cart, checkout, orders

restart-all.sh orchestrates Anvil + both deploys + 4 apps

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- fix(restart-all.sh): use taskkill to reliably kill anvil.exe on Windows
- fix(restart-all.sh): replace --root flag with cd-based approach (--root incompatible with Unix paths on Windows forge.exe)
- fix(restart-all.sh): clear broadcast/cache dirs before each deploy to avoid stale state conflicts
- fix(restart-all.sh): show forge output on failure for easier debugging
- chore: add package-lock.json and next-env.d.ts for all 4 Next.js apps (generated by npm install)
- chore: tsconfig.json reformatted by Next.js (expanded arrays)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- add .gitattributes: force LF line endings for all .sh, .sol, .ts, .json, .md files
  (prevents CRLF issues when running .sh scripts from WSL)
- docs: add section §11 P03 E-Commerce with Windows-specific lessons:
  forge --root incompatible with Unix paths, pkill vs taskkill, broadcast cache
  conflicts, set -e swallowing forge errors, cast send for testing without Stripe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- trap cleanup on EXIT/INT/TERM: kills all child PIDs, node.exe, anvil.exe
- track CHILD_PIDS for Anvil and all 4 Next.js apps
- preserve existing Stripe keys from .env.local instead of overwriting
  with bash ${VAR:-placeholder} syntax that Next.js doesn't expand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use eth_accounts (silent) on mount to restore wallet session without
prompting. Also update accountsChanged handler to reconnect when user
switches accounts instead of just disconnecting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant