BlueDragonIO — Full Project Analysis

A full-stack NFT marketplace on Polygon. This document explains the project's purpose, how each component works, and how data/processes flow through the system.


1. What the project is for

BlueDragonIO (blue-dragon.io) is a full-stack NFT marketplace on the Polygon blockchain (chain 137). It sells 1-of-1 "membership" NFTs (DMS e-Solution Gold/Silver tiers, plus a "BluePass" collection) marketed as profit-sharing assets ("NFTs for profit").

Its distinguishing goal is to make Web3 purchasing feel like ordinary e-commerce: users sign in with their wallet, browse collections, add to cart, and pay with either a credit card / PayPal (Stripe) or USDT stablecoin. The platform then mints the NFT to them automatically, splits the revenue on-chain across a dozen team/company wallets, tracks referral rewards, and lets users withdraw those rewards — with all treasury movements guarded by a Gnosis Safe multisig so no single server key can drain funds.


2. The four components (repo layout)

The root is a monorepo of four independently-deployed services:

Directory Component Stack Role
backend-master/ API + blockchain engine Laravel 11 / PHP 8.2, MySQL, Redis The brain: auth, catalog, orders, payments, minting, on-chain indexing, revenue split
frontend_nuxt-main/ Web app Nuxt 3 / Vue 3, Pinia, Reown AppKit + wagmi/viem User & admin UI; wallet connection & signing
dms_smart_contracts-main/ Smart contracts Solidity 0.8.24, Hardhat + Ignition, OpenZeppelin v5 The on-chain NFT (ERC-1155) and swap contracts
safe-wallet-helper-main/ swh CLI Node/TypeScript (esbuild), Safe SDK, viem Bridge for proposing Gnosis Safe multisig transactions

3. How each component works

A. Smart contracts (dms_smart_contracts-main)

DragonNftV2.sol — the live production NFT contract. An ERC-1155 enriched with AccessControl, Pausable, Supply, and ERC2981 royalties.

DragonSwapV2.sol — a migration/swap contract. It exists because a prior provider (Venly) assigned different ids to the old NFTs. It uses the ERC-1155 receiver-callback pattern: a user calls safeTransferFrom(user, swapContract, oldId, 1) on the old contract; that fires onERC1155Received, which looks up newId = oldIdToNewIdMap[oldId] and mints (or transfers) the correctly-numbered new NFT to the user.

Supporting: DragonNft.sol / DragonSwap.sol (legacy v1, still live), DragonNft_721.sol (unused ERC-721 variant), TestToken.sol (a fake USDT ERC-20 for staging). Deployment is scripted via Hardhat Ignition modules (ignition/modules/*.ts) targeting Polygon.

Key insight: the contracts contain no payment/escrow logic. Pricing, fiat, and USDT collection all happen off-chain in the backend, which — holding MINTER_ROLE — mints the NFT after it confirms payment.

B. Backend (backend-master) — the engine

Authentication — Sign-In With Ethereum (SIWE / EIP-4361): Web3Controller issues a server nonce (/web3/nonce) and message args (/web3/message-args, chains:[137]); the user signs it in their wallet; /web3/login-verify verifies the signature (iltumio/siwe-php), recovers the address, creates/loads the User + UserWallet, and issues a Laravel Sanctum bearer token. No passwords.

HD-wallet key management (BlockchainManagerService + BlockchainService): the backend holds a master BIP-39 mnemonic and derives keys via BIP-44 path m/44'/chainId'/account'/0/addressIndex. Two crucial patterns:

BlockchainService builds, gas-estimates (+15% buffer), signs (web3p/ethereum-tx), and broadcasts raw transactions — mintDragonNft, transferErc20, native MATIC transfer, event-log readers, and metadata fetchers.

Domain models fall into four clusters:

Payment flow (both rails converge):

  1. UserOrderController@checkout reserves products (15 min), applies discounts/fees, creates the Order (40-min expiry).
  2. Card/PayPal → Stripe Checkout session; on completion StripeController/StripeWebhookController marks the order paid. USDT → user gets the per-order deposit address; the every-minute app:check-order-usdt-payment scheduler dispatches CheckOrderPayment, which compares the on-chain USDT balance to the order total.
  3. Either path fires PaymentVerified + MoneyTransfered and dispatches a MintNftJob per product → mints the ERC-1155 to the buyer's wallet.
  4. Revenue segmentation: SegmentationsListener computes a weighted split (company, dev team, core team, CEO, COO, marketing, commission, collection fee, referral reward) from CollectionRatio; DoSegmentationsJob moves each USDT share on-chain from the order wallet to the destination wallets; referral rewards credit the referrer's UserBalance.

Async / scheduled work (Redis queues): MintNftJob, CheckOrderPayment, FetchBlockchainNftEventLogsProcessBlockchainNftEventLogs (an event indexer that rebuilds BlockchainLogNftOwnership from Transfer logs), FetchBlockchainNftMetadata, ApplyBlockchainData (backfills historical/migrated mints), and ProcessWithdrawRequest.

Withdrawals via Gnosis Safe: WithdrawController creates a WithdrawRequest; ProcessWithdrawRequest calls BlockchainService::proposeTransferErc20ToSafe, which shells out to the swh CLI to propose the payout from the multisig rewards wallet. A human Safe owner must approve.

C. Frontend (frontend_nuxt-main) — the UI

Nuxt 3 SPA/SSR using Reown AppKit (formerly WalletConnect Web3Modal) + wagmi + viem, restricted to Polygon. State in Pinia (auth, cart stores, cookie-persisted, cross-tab synced). API calls go through a $api $fetch client that attaches the Sanctum bearer token (cookie auth-jwt) and auto-logs-out on 401.

D. Safe Wallet Helper (safe-wallet-helper-main) — the swh CLI

A small Node/TypeScript CLI (built with esbuild to dist/swh.js, invoked by the backend as node /var/www/swh/dist/swh.js). It uses the official Safe SDK (@safe-global/api-kit + protocol-kit) and viem. Two commands:

This keeps the platform's treasury under multisig control — the backend can propose payouts but a human owner must approve them.


4. System architecture diagram

[Diagram]

5. Core workflow — purchase → mint → revenue split

[Diagram]

6. Two supporting workflows

NFT migration swap (old wrong-id NFT → new correct-id NFT)

[Diagram]

Referral-reward withdrawal (multisig-guarded)

[Diagram]

7. Analytical summary


8. Key files reference

Smart contracts

Backend (blockchain core)

Frontend

Safe helper