Pay with Euros Online, Settled in Blockchain: How Stablecoins Bridge Web2 and Web3

💡 The Value Proposition: What if you could accept Euro payments online with 0.1% fees instead of 3% credit card processing? Our decentralized e-commerce platform lets customers pay with credit cards via Stripe, while the backend automatically converts them into a custom EUR-pegged stablecoin (EURT) on-chain. Web2 convenience meets Web3 efficiency.

🎯 The Problem: Why "Accept Crypto" Isn't E-Commerce

Most Web3 e-commerce projects make one simple thing: accept ETH or USDC as a payment method. This is like putting a "Bitcoin accepted here" sign on a traditional online store. It doesn't solve the fundamental problems:

Traditional E-Commerce "Accept Crypto" Stores Our Approach
3% credit card fees Volatile crypto prices EUR-pegged stablecoin
Instant confirmation 10+ min blockchain settlement Near-instant on Solana/EVM
Chargebacks possible Irreversible transactions Programmable refund logic
No on-chain data No business intelligence Full on-chain analytics

This project goes further: it doesn't just accept crypto — it issues its own stablecoin pegged to the Euro (EURT) and builds a complete e-commerce ecosystem on top of it.

💡 The Architecture: Four Projects, One Ecosystem

The project is a monorepo composed of four sub-projects that interact with each other:

flowchart TD
    Customer["🛒 Customer<br/>(Credit Card)"] --> Stripe["💳 Stripe API<br/>(Payment Processing)"]
    Stripe --> Webhook["🔔 Webhook<br/>(Payment Confirmed)"]
    Webhook --> Backend["⚙️ Backend<br/>(Verification + Mint)"]
    Backend --> EURT["🪙 EURT Token<br/>(ERC-20 Stablecoin)"]
    
    Customer --> WebCustomer["🌐 Web Customer<br/>(Next.js dApp)"]
    WebCustomer --> EURT
    EURT --> Products["📦 Products<br/>(Smart Contracts)"]
    Products --> WebCustomer
    
    Admin["👨‍💼 Administrator"] --> WebAdmin["🖥️ Web Admin<br/>(Next.js Dashboard)"]
    WebAdmin --> Products
    WebAdmin --> EURT
    WebAdmin --> Companies["🏢 Companies<br/>(Registration)"]

Project Structure

ecommerce/ ├── sc-ecommerce/ ← Store Smart Contracts (Solidity/Foundry) ├── stablecoin/sc/ ← EURT Token Smart Contract (ERC-20) ├── web-customer/ ← dApp for Buyers (Next.js + Wagmi) └── web-admin/ ← Administration Dashboard (Next.js)

🛠️ The EURT Token: Euro on the Blockchain

// Euro-pegged stable token // Precision: 6 decimals (like USDC, represents cents) // Controlled issuance: only the owner can mint // Standard: ERC-20 (OpenZeppelin)

Why 6 Decimals?

Token Decimals Representation
ETH 18 0.000000000000000001 ETH
USDC 6 1.00 = $1.00
EURT (This Project) 6 1.00 = €1.00
Traditional Math 2 1.00 = 1 Euro

The decision to use 6 decimals (instead of ETH's standard 18) is intentional: it represents Euro cents precisely, avoiding truncation problems in price calculations. 1 EURT = €1.00, 0.01 EURT = €0.01 (one cent).

The Fiat → Crypto On-Ramp

The most innovative flow is how traditional payments become blockchain tokens:

sequenceDiagram
    participant Customer
    participant Stripe as Stripe API
    participant Backend
    participant EURT as EURT Contract
    participant Wallet as Customer Wallet
    
    Customer->>Stripe: Enter credit card details
    Stripe->>Stripe: Process payment (3D Secure)
    Stripe-->>Backend: Webhook: payment_intent.succeeded
    Backend->>Backend: Verify payment_intent_id<br/>(idempotency check)
    Backend->>EURT: mint(customer, amount)
    EURT-->>EURT: EURT created in customer wallet
    EURT-->>Wallet: ✅ EURT received
    Wallet-->>Customer: 🛒 Ready to shop

⚠️ Critical Design Decision: Idempotency If Stripe's webhook is sent twice (which it does on retry), the contract could mint twice. The solution: register each payment_intent_id in the contract to prevent duplicate mints.

Smart Contract Architecture

The e-commerce contracts use a Modular Libraries architecture in Solidity:

flowchart LR
    MainContract["📜 Main E-Commerce<br/>Contract"]
    
    MainContract --> CompanyLib["🏢 CompanyLib<br/>(Registration + Activation)"]
    MainContract --> ProductLib["📦 ProductLib<br/>(CRUD + Stock)"]
    MainContract --> CustomerLib["👤 CustomerLib<br/>(Registration)"]
    MainContract --> CartLib["🛒 ShoppingCartLib<br/>(Cart + Totals)"]
Library Responsibility
CompanyLib Business registration and activation
ProductLib Product CRUD, on-chain stock control
CustomerLib Customer registration
ShoppingCartLib Cart and total calculation

Payment State Machine

stateDiagram-v2
    [*] --> Pending: Customer places order
    Pending --> Completed: Payment confirmed
    Pending --> Failed: Payment failed / timeout
    Completed --> Refunded: Customer requests refund
    Completed --> [*]: Order fulfilled
    Failed --> [*]: Order cancelled
    
    note right of Pending
        EURT locked in contract
        Stock reserved
    end note
    
    note right of Completed
        EURT released to merchant
        Stock deducted
    end note

💻 Frontend: Two Interfaces, One System

For Customers (web-customer)

flowchart TD
    Landing["🏠 Landing Page"] --> Connect["🔗 Connect Wallet"]
    Connect --> Browse["📦 Browse Products"]
    Browse --> Cart["🛒 Add to Cart"]
    Cart --> Checkout["💳 Checkout via Stripe"]
    Checkout --> StripeAuth["🔐 Stripe 3D Secure"]
    StripeAuth --> Mint["⏳ EURT Minting..."]
    Mint --> Shop["🛍️ Shop with EURT"]
    Shop --> Order["📦 Track Orders"]

Technology Stack:

  • Next.js 15 — Server-side rendering for SEO
  • Wagmi v2 — React hooks for Ethereum interaction
  • Viem — Type-safe Ethereum client
  • Stripe Elements — Secure payment form

For Administrators (web-admin)

flowchart LR
    Dashboard["📊 Dashboard<br/>(Sales Metrics)"] --> Inventory["📦 Inventory<br/>(Stock Management)"]
    Dashboard --> Companies["🏢 Company<br/>(Registration)"]
    Inventory --> Products["📝 Product<br/>(CRUD)"]
    Companies --> Orders["📋 Orders<br/>(Fulfillment)"]

📈 Impact: What This Architecture Enables

Metric Traditional E-Commerce This Project
Payment Fees 2.9% + €0.30 ~0.1% gas fees
Settlement Time 2-3 days < 30 seconds
Chargebacks Possible Impossible (programmable)
Cross-Border FX fees + delays Same EURT everywhere
Transparency Opaque (provider) Fully on-chain
Operating Hours Business hours 24/7/365

Real-World Example: A Purchase Flow

1. Customer adds €50 EURT products to cart 2. Pays with credit card via Stripe (€50 + 3.5% fee) 3. Stripe webhook confirms payment → Backend mints 50 EURT 4. Customer receives 50 EURT in wallet 5. Customer swaps EURT for products on dApp 6. Smart contracts update stock, transfer EURT to merchant 7. Administrator sees sale metrics in dashboard

🔗 Why This Matters Beyond E-Commerce

This project demonstrates that the bridge between traditional finance and blockchain is already built. Stripe integration proves that Web2 payment infrastructure can work with Web3 smart contracts — not as competitors, but as complementary layers.

The progression is natural: First, you learn how to move value with a stablecoin (this post). Then, you learn how to secure that value with role-based governance (RWA Security Agents). Finally, you see how it all fits into the bigger picture of institutional finance (RWA Conclusion).

The Future: Programmable Commerce

Imagine a world where:

  • Refunds are automatic — if a product doesn't arrive, smart contracts return the EURT
  • Royalties are instant — creators receive their cut on every resale automatically
  • Compliance is built-in — only verified wallets can transerve certain assets
  • Analytics are real-time — every transaction is visible on-chain, no black boxes

✅ Key Takeaways

  1. EURT is a custom ERC-20 stablecoin pegged to the Euro with 6 decimals (represents cents)
  2. Stripe integration bridges Web2 and Web3 — customers pay with cards, blockchain handles settlement
  3. Idempotency is criticalpayment_intent_id registration prevents duplicate mints from webhook retries
  4. Modular libraries architecture — separate concerns (Company, Product, Customer, Cart) for maintainability
  5. Two frontends, one backend — customer dApp for shopping, admin dashboard for management
  6. State machine for payments — Pending → Completed → (Refunded | Failed)
  7. 0.1% fees vs 3% credit card fees — the economic incentive for blockchain commerce is real

📋 Table of Contents


📊 Stablecoin Performance Metrics

Metric Traditional Payment (Stripe) EURT on Ethereum EURT on Solana
Processing fee 2.9% + €0.30 ~0.1% gas ~0.00001%
Settlement time T+2 business days ~15 seconds <1 second
Cross-border fee FX + transfer (~3-5%) Same EURT everywhere Same EURT everywhere
Min. transaction €0.50 €0.01 (1 cent) €0.001
Operational hours Business hours only 24/7/365 24/7/365
Chargeback rate 0.5-1.5% of transactions 0% (programmable) 0% (programmable)

🔗 Continuous Learning

Deepen your understanding of stablecoins and e-commerce blockchain integration:

Resource Type Focus Link
ERC-20 Token Standard Official EIP-20 specification ethereum.org
USDC Technical Documentation Official Stablecoin architecture circle.com
Stripe API Documentation Official Payment processing integration stripe.com
Wagmi v2 Documentation Library React hooks for Ethereum wagmi.sh
DeFi E-Commerce Research - Deloitte Research Web3 retail trends deloitte.com

💬 Want to Contribute?

This e-commerce ecosystem is open-source and welcomes contributions:

Contribution Type How to Help Impact
🪙 Stablecoin Integration Add EURT to new platforms/chains Expand reach
💳 Payment Gateway Integrate alternative fiat on-ramps More onboarding options
🛒 Store Templates Create Next.js storefront templates Help merchants launch
📝 Documentation Improve guides and API docs Lower barrier to entry

Explore other projects from the Blockchain and Web3 Master:

Article Focus Link
E-Commerce Migration to Solana Migration from EVM to Solana
Supply Chain Tracker on Blockchain RBAC traceability with Solidity
Document Signing with Blockchain EIP-712 signatures for documents
RWA Security Agents on Solana PDA-based access control

🔗 Explore the Implementation

The complete e-commerce ecosystem is available in the following repository:

Resource Description Link
Main Repository Full monorepo with all 4 sub-projects github.com/87maxi/ecommerce
EURT Smart Contract ERC-20 stablecoin with controlled minting ecommerce/stablecoin/sc
E-Commerce Contracts Store logic with modular libraries ecommerce/sc-ecommerce
Customer dApp Next.js frontend for buyers ecommerce/web-customer
Admin Dashboard Next.js frontend for administrators ecommerce/web-admin
Foundry Tests Comprehensive test suite for all contracts ecommerce/sc-ecommerce/test
💬

Comments

Powered by Giscus · GitHub Discussions

🧠 Web3 & Blockchain