Skip to content

mochiyaki/monster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monster

- Blockchain-based Banking and NFT Shop System

This project is a comprehensive blockchain-based system that combines a banking contract with an NFT shop contract, built on the Arc testnet. It features a full-stack implementation with smart contracts, backend API server, and frontend interface.

screenshot

try it out here (make sure your metamask or compatible wallet extension installed)

Project Overview

The Monster project is a decentralized application (dApp) that combines:

  • A Bank contract for managing USDC deposits and withdrawals
  • An NFT Shop contract for minting and managing ERC721 NFTs
  • A backend API server that connects to the blockchain
  • A frontend interface for user interaction

This system demonstrates how blockchain technology can be used for both financial services and digital asset management in a unified platform.

Project Structure

monster/
├── backend/
│   ├── contracts/
│   │   ├── Bank.sol         # Bank smart contract
│   │   └── Shop.sol         # NFT shop smart contract
│   ├── scripts/
│   │   └── deploy.js        # Deployment script
│   ├── server.js            # Backend API server
│   ├── hardhat.config.js    # Hardhat configuration
│   ├── package.json         # Backend dependencies
│   └── README.md            # Backend documentation
│
├── frontend/
│   ├── index.html           # Main HTML file
│   ├── package.json         # Frontend dependencies
│   ├── src/
│   │   ├── App.tsx          # Main React component
│   │   ├── main.tsx         # Entry point
│   │   └── index.css        # Styles
│   ├── vite.config.ts       # Vite configuration
│   ├── tailwind.config.js   # Tailwind CSS configuration
│   └── postcss.config.js    # PostCSS configuration
│
├── bank.sol                 # Bank contract source
├── shop.sol                 # Shop contract source
├── package.json             # Root dependencies
├── README.md                # This file
└── demo.gif                 # Project demonstration

System Workflow

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Frontend      │    │   Backend API   │    │   Blockchain    │
│   (React)       │    │   (Node.js)     │    │   (Arc Testnet) │
└─────────────────┘    └─────────────────┘    └─────────────────┘
        │                       │                       │
        │ 1. User actions       │                       │
        │ ────────────────────▶│                       │
        │                       │                       │
        │                       │ 2. Contract calls     │
        │                       │ ────────────────────▶│
        │                       │                       │
        │                       │ 3. Transaction       │
        │                       │    broadcast          │
        │                       │ ────────────────────▶│
        │                       │                       │
        │                       │ 4. Transaction        │
        │                       │    confirmation       │
        │                       │ ◀─────────────────── │
        │                       │                       │
        │ 5. Response           │                       │
        │ ◀─────────────────── │                       │
        │                       │                       │
        │ 6. UI update          │                       │
        │ ◀─────────────────── │                       │
        │                       │                       │

Smart Contracts

1. Bank Contract (bank.sol)

A simple bank contract that allows users to deposit and withdraw USDC (under Arc testnet).

Key Features:

  • deposit() - Accepts USDC deposits from users
  • withdraw(address to, uint amount) - Withdraws USDC to a specified address
  • balances - Mapping to track user balances
  • Secure transaction handling with proper error management

2. Shop Contract (shop.sol)

An ERC721 NFT shop contract that allows users to mint and manage NFTs.

Key Features:

  • mint(string memory _name, string memory _image) - Mint new NFTs
  • modifyPig(uint _id, string memory _name, string memory _image) - Modify existing NFTs
  • tokenURI(uint _id) - Returns metadata for NFTs
  • getPig(uint _id) - Retrieve NFT information
  • getBalance() - Check contract balance
  • Owner-only functions for shop management:
    • changeOwner(address newOwner)
    • setPigFee(uint _cost)
    • redeem(address _to, uint _amount)
    • closeShop(bool _close)

Dependencies:

  • Uses OpenZeppelin's ERC721 implementation
  • Uses OpenZeppelin's Base64 library for metadata encoding

Backend API Server

The backend server provides RESTful API endpoints to interact with the smart contracts:

API Endpoints

Bank Endpoints:

  • POST /bank/deposit - Deposit funds into the bank contract
  • POST /bank/withdraw - Withdraw funds from the bank contract
  • GET /bank/balance/:address - Get user balance

Shop Endpoints:

  • POST /shop/mint - Mint new NFTs
  • GET /shop/get-pig/:id - Get NFT information
  • GET /shop/balance - Get shop contract balance

Server Features:

  • Express.js based API server
  • Contract interaction using Hardhat
  • JSON response handling
  • Error management
  • Environment configuration support

Frontend Interface

The frontend is a React-based interface that allows users to interact with the system:

  • User-friendly interface for banking operations
  • NFT minting and viewing capabilities
  • Real-time balance updates
  • Responsive design using Tailwind CSS

Deployment

Prerequisites

  1. Install Node.js and npm
  2. Create a .env file in the backend directory with your private key:
    PRIVATE_KEY=your_private_key_here
    

Local Deployment

To deploy contracts to the local Hardhat network:

cd backend
npx hardhat run scripts/deploy.js --network hardhat

Testnet Deployment (Arc)

To deploy to the Arc testnet:

cd backend
npx hardhat run scripts/deploy.js --network arc

Running the Application

  1. Start the backend server:
    cd backend
    node server.js
  2. Start the frontend development server:
    cd frontend
    npm run dev

Contract Deployment Addresses

License

This project is under MIT License

Contributing Guidelines

  • Welcome to all contributors
  • For agentic-commerce-on-arc submission recently
  • Please follow the code style and testing guidelines
  • Submit pull requests for review

Future Improvements

  • Add more comprehensive frontend features
  • Implement user authentication
  • Add advanced contract management
  • Include more detailed analytics
  • Expand NFT functionality

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors