Skip to content

Latest commit

 

History

History

README.md

Infinity

Infinity Contracts

Solidity Hardhat Next.js The Graph TypeScript Node

📑 Table of Contents

💡 About the Project

Infinity Contracts is a Web3 project that implements an NFT-based promotion system for redeeming free tacos. The project consists of smart contracts for managing NFT promotions, a Next.js frontend for user interaction, and a subgraph for indexing blockchain data.

Key Features

  • 🎫 NFT-based promotion system
  • 🌮 Redeemable tokens for free tacos
  • 📊 Real-time blockchain data indexing
  • 🔍 Block explorer functionality
  • 🎨 Modern Web3 frontend interface
  • 🔐 Secure smart contract architecture

🛠 Tech Stack

Smart Contracts

  • Language: Solidity ^0.8.0
  • Framework: Hardhat
  • Libraries: OpenZeppelin

Frontend

  • Framework: Next.js
  • Web3 Integration: wagmi, RainbowKit
  • Styling: Tailwind CSS

Indexing & Data

  • Indexing: The Graph
  • Query Language: GraphQL

Development Tools

  • Language: TypeScript
  • Testing: Hardhat Test Suite
  • Linting: ESLint, Prettier
  • Package Manager: Yarn

📁 Project Structure

InfinityContracts/
├── packages/
│   ├── hardhat/              # Smart contract development
│   │   ├── contracts/        # Solidity smart contracts
│   │   ├── deploy/           # Deployment scripts
│   │   └── test/            # Contract tests
│   │
│   ├── nextjs/              # Frontend application
│   │   ├── app/             # Next.js pages & components
│   │   ├── components/      # Reusable components
│   │   └── hooks/           # Custom React hooks
│   │
│   └── subgraph/            # The Graph indexing
│       ├── src/             # GraphQL schema & mappings
│       └── tests/           # Subgraph tests

📝 Smart Contracts

InfinityPromotion

The main smart contract implementing the NFT-based promotion system:

contract InfinityPromotion is ERC721, Pausable, Ownable {
    // Core functionality
    function claimToken() external returns (uint256)
    function redeemToken(uint256 tokenId) external
    function isTokenRedeemed(uint256 tokenId) external view returns (bool)
    
    // Admin functions
    function pause() external onlyOwner
    function unpause() external onlyOwner
    function extendPromotion(uint256 extension) external onlyOwner
}

Key Features:

  • 🎟️ ERC721-based NFT tokens
  • ⏱️ Time-limited promotions
  • 🔒 Pausable functionality
  • 📊 Token tracking system
  • 🎫 Redemption management

🚀 Getting Started

Prerequisites

node -v  # >= 20.18.1
yarn -v  # >= 3.2.3

Installation

  1. Clone the repository
git clone https://github.com/your-org/infinity-contracts.git
cd infinity-contracts
  1. Install dependencies
yarn install
  1. Set up environment variables
# In packages/hardhat
cp .env.example .env
# In packages/nextjs
cp .env.example .env
  1. Start local blockchain
yarn chain
  1. Deploy contracts
yarn deploy
  1. Start frontend
yarn start

📜 Available Scripts

Smart Contract Development

# Hardhat
yarn hardhat:compile     # Compile contracts
yarn hardhat:test       # Run tests
yarn hardhat:deploy     # Deploy contracts
yarn hardhat:verify     # Verify contracts

# Account management
yarn account            # List accounts
yarn account:generate   # Generate new account
yarn account:import     # Import account

Frontend Development

yarn start             # Start Next.js dev server
yarn next:build        # Build frontend
yarn next:serve        # Serve production build

Subgraph Development

yarn subgraph:codegen  # Generate types
yarn subgraph:build    # Build subgraph
yarn subgraph:deploy   # Deploy subgraph

🚢 Deployment

Smart Contracts

  1. Configure network in hardhat.config.ts
  2. Set deployment parameters in .env
  3. Deploy contracts:
yarn deploy --network <network-name>
  1. Verify contracts:
yarn verify --network <network-name>

Frontend

  1. Configure environment variables
  2. Build and deploy:
yarn next:build
yarn vercel

Subgraph

  1. Update subgraph manifest
  2. Deploy to The Graph:
yarn subgraph:deploy

🤝 Contributing

Development Process

  1. Fork the repository
  2. Create your feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m 'Add some AmazingFeature'
  4. Push to the branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Code Style

  • Follow Solidity style guide
  • Use TypeScript for frontend code
  • Write comprehensive tests
  • Document all functions and components
  • Follow existing naming conventions

Built with 🖤 by the Infinity Team