Skip to content

mrbrightsides/sct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“š SCT by STC - Platform Documentation

Smart Contract Template Marketplace


๐ŸŒŸ Ringkasan Aplikasi / App Summary

SCT by STC adalah platform marketplace komprehensif untuk smart contract template yang memudahkan developer, startup, bisnis, dan educator dalam menemukan, kustomisasi, dan deploy template Solidity smart contract.

SCT by STC is a comprehensive smart contract template marketplace platform that facilitates developers, startups, businesses, and educators in discovering, customizing, and deploying Solidity smart contract templates.


๐ŸŽฏ Fitur Utama / Key Features

1. Template Library (21+ Templates)

  • Kategori: NFT, DeFi, DAO, Token, Gaming, Marketplace, Governance, dan lainnya
  • Interactive Preview: Preview langsung kode contract sebelum deploy
  • View Code & Export: Lihat source code lengkap dengan opsi export (Copy, Download, atau IPFS)

2. Real Blockchain Integration ๐Ÿ”—

  • Wallet Connection: Integrasi MetaMask via wagmi/ethers.js
  • Multi-Network Support:
    • Base Mainnet (Chain ID: 8453)
    • Base Sepolia Testnet (Chain ID: 84532)
    • Ethereum Mainnet (Chain ID: 1)
    • Sepolia Testnet (Chain ID: 11155111)
  • Network Switching: Auto-switch network dari deployment panel
  • Gas Estimation: Estimasi gas fees sebelum deploy

3. One-Click Deployment ๐Ÿš€

  • Deploy smart contract langsung ke blockchain pilihan
  • Real transaction tracking dengan block explorer links
  • Contract verification support
  • Transaction status monitoring real-time

4. IPFS Storage Integration ๐Ÿ“ฆ

  • Upload contract metadata ke IPFS via Pinata SDK
  • Decentralized storage untuk source code dan ABI
  • Fallback ke localStorage jika Pinata belum dikonfigurasi
  • Permanent, immutable contract storage

5. Community Hub ๐Ÿ‘ฅ

Fitur interaktif dengan persistent storage:

a. Start Discussion

  • Post pertanyaan dan diskusi
  • Share pengetahuan tentang smart contracts
  • Activity feed untuk diskusi terbaru

b. Submit Template

  • Upload smart contract template baru
  • IPFS-backed storage
  • Include metadata: name, category, description, code

c. Review Code

  • Rate dan review templates (1-5 stars)
  • Berikan feedback konstruktif
  • View review history

d. Share Project

  • Showcase deployed contracts
  • Include contract address dan network info
  • Link ke block explorer
  • Share achievements dengan community

๐Ÿ—๏ธ Arsitektur Aplikasi / App Architecture

SCT by STC
โ”‚
โ”œโ”€โ”€ Frontend (Next.js + React)
โ”‚   โ”œโ”€โ”€ UI Components (shadcn/ui)
โ”‚   โ”œโ”€โ”€ Wallet Connection (wagmi + ethers.js)
โ”‚   โ””โ”€โ”€ State Management (React Hooks)
โ”‚
โ”œโ”€โ”€ Blockchain Layer
โ”‚   โ”œโ”€โ”€ Smart Contract Deployment
โ”‚   โ”œโ”€โ”€ Network Switching
โ”‚   โ”œโ”€โ”€ Transaction Management
โ”‚   โ””โ”€โ”€ Gas Estimation
โ”‚
โ”œโ”€โ”€ Storage Layer
โ”‚   โ”œโ”€โ”€ IPFS (Pinata SDK)
โ”‚   โ”œโ”€โ”€ LocalStorage (Fallback)
โ”‚   โ””โ”€โ”€ Community Data Persistence
โ”‚
โ””โ”€โ”€ Services
    โ”œโ”€โ”€ BlockchainService (src/lib/blockchain.ts)
    โ”œโ”€โ”€ IPFSService (src/lib/ipfs.ts)
    โ””โ”€โ”€ StorageService (src/lib/storage.ts)

๐Ÿ“‚ Struktur File / File Structure

Core Application

src/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ page.tsx                 # Main landing page
โ”‚   โ”œโ”€โ”€ layout.tsx               # Root layout dengan Web3Provider
โ”‚   โ””โ”€โ”€ globals.css              # Global styles (neon web3 theme)
โ”‚
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ AboutApp.tsx             # Tentang aplikasi (Indonesian)
โ”‚   โ”œโ”€โ”€ CommunitySection.tsx    # Community hub interface
โ”‚   โ”œโ”€โ”€ DeploymentPanel.tsx     # Blockchain deployment panel
โ”‚   โ”œโ”€โ”€ TemplateCard.tsx        # Template display card
โ”‚   โ”œโ”€โ”€ WalletConnection.tsx    # MetaMask connection UI
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ Modals/
โ”‚   โ”‚   โ”œโ”€โ”€ PreviewTemplateModal.tsx    # Interactive preview
โ”‚   โ”‚   โ”œโ”€โ”€ ViewCodeModal.tsx           # Code viewer + export
โ”‚   โ”‚   โ”œโ”€โ”€ DeployModal.tsx             # Deployment interface
โ”‚   โ”‚   โ”œโ”€โ”€ StartDiscussionModal.tsx    # Discussion creator
โ”‚   โ”‚   โ”œโ”€โ”€ SubmitTemplateModal.tsx     # Template uploader
โ”‚   โ”‚   โ”œโ”€โ”€ ReviewCodeModal.tsx         # Review system
โ”‚   โ”‚   โ””โ”€โ”€ ShareProjectModal.tsx       # Project showcase
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ui/                     # shadcn/ui components
โ”‚
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ blockchain.ts           # ๐Ÿ”ฅ Blockchain service (ethers.js)
โ”‚   โ”œโ”€โ”€ ipfs.ts                 # ๐Ÿ”ฅ IPFS storage (Pinata)
โ”‚   โ”œโ”€โ”€ storage.ts              # ๐Ÿ”ฅ Persistent storage
โ”‚   โ””โ”€โ”€ wagmi-config.ts         # Wagmi configuration
โ”‚
โ”œโ”€โ”€ hooks/
โ”‚   โ”œโ”€โ”€ useContractDeployment.ts    # Deployment logic
โ”‚   โ”œโ”€โ”€ useIPFSStorage.ts           # IPFS operations
โ”‚   โ”œโ”€โ”€ useCommunityStorage.ts      # Community data
โ”‚   โ””โ”€โ”€ useSmartContract.ts         # Contract interactions
โ”‚
โ”œโ”€โ”€ providers/
โ”‚   โ””โ”€โ”€ Web3Provider.tsx        # Web3 context provider
โ”‚
โ””โ”€โ”€ types/
    โ””โ”€โ”€ template.ts             # TypeScript interfaces

๐Ÿ”„ Alur Kerja Aplikasi / App Workflow

1. User Journey - Browse Templates

User masuk app โ†’ Browse 21+ templates โ†’ Filter by category โ†’
Preview template โ†’ View code โ†’ Choose: Export or Deploy

2. User Journey - Deploy Contract

Click "Deploy to Blockchain" โ†’ Connect MetaMask โ†’
Select network (Base/Ethereum/Sepolia) โ†’ Review gas fees โ†’
Confirm transaction โ†’ Track deployment โ†’ Get contract address โ†’
View on block explorer

3. User Journey - Community Engagement

Navigate to Community Hub โ†’
Choose action:
  โ”œโ”€โ”€ Start Discussion (Post question)
  โ”œโ”€โ”€ Submit Template (Upload contract + IPFS)
  โ”œโ”€โ”€ Review Code (Rate template)
  โ””โ”€โ”€ Share Project (Showcase deployment)
โ†’ Submit โ†’ Data persisted to storage โ†’ Activity feed updated

4. Technical Flow - Smart Contract Deployment

// Step-by-step deployment process

1. User clicks "Deploy" on template
   โ†“
2. WalletConnection checks MetaMask
   โ†“
3. User selects target network
   โ†“
4. BlockchainService.estimateGas()
   โ†“
5. User confirms with gas estimate
   โ†“
6. BlockchainService.deployContract()
   - Compiles Solidity code
   - Estimates gas
   - Sends transaction
   - Waits for confirmation
   โ†“
7. Transaction hash returned
   โ†“
8. IPFSService.uploadMetadata()
   - Uploads contract metadata to IPFS
   - Returns IPFS hash
   โ†“
9. StorageService.saveDeployment()
   - Saves deployment record
   โ†“
10. Success! Display contract address + explorer link

5. Technical Flow - IPFS Storage

// IPFS upload process

1. User submits template/project
   โ†“
2. Prepare metadata object:
   {
     name, description, code,
     abi, bytecode, network,
     timestamp, author
   }
   โ†“
3. IPFSService.uploadToIPFS()
   โ†“
4. Check Pinata API configuration
   โ”œโ”€ If configured: Upload to Pinata
   โ””โ”€ If not: Fallback to localStorage
   โ†“
5. Return IPFS hash (or local reference)
   โ†“
6. Save hash to storage for future retrieval

๐Ÿ› ๏ธ Service Layer Detail

BlockchainService (src/lib/blockchain.ts)

Fungsi Utama / Main Functions:

// Initialize provider dengan network
initializeProvider(chainId: number): JsonRpcProvider

// Deploy smart contract
deployContract(
  sourceCode: string,
  contractName: string,
  signer: Signer,
  constructorArgs?: any[]
): Promise<{
  address: string;
  transactionHash: string;
  blockNumber: number;
}>

// Estimate gas untuk deployment
estimateGas(
  sourceCode: string,
  signer: Signer
): Promise<bigint>

// Switch network di MetaMask
switchNetwork(chainId: number): Promise<void>

// Get block explorer URL
getExplorerUrl(
  chainId: number,
  address: string,
  type: 'address' | 'tx'
): string

Supported Networks:

  • Base Mainnet: https://mainnet.base.org
  • Base Sepolia: https://sepolia.base.org
  • Ethereum: https://eth.llamarpc.com
  • Sepolia: https://rpc.sepolia.org

IPFSService (src/lib/ipfs.ts)

Fungsi Utama / Main Functions:

// Upload contract metadata ke IPFS
uploadToIPFS(metadata: ContractMetadata): Promise<string>

// Retrieve metadata dari IPFS
getFromIPFS(hash: string): Promise<ContractMetadata>

// Check Pinata API configuration
isPinataConfigured(): boolean

// Generate metadata object
generateMetadata(
  name: string,
  code: string,
  network: string,
  author?: string
): ContractMetadata

Metadata Structure:

{
  "name": "Contract Name",
  "description": "Description",
  "sourceCode": "// Solidity code",
  "abi": [...],
  "bytecode": "0x...",
  "compiler": "0.8.20",
  "network": "Base",
  "timestamp": 1234567890,
  "author": "0x...",
  "ipfsHash": "Qm..."
}

StorageService (src/lib/storage.ts)

Fungsi Utama / Main Functions:

// Community discussions
saveDiscussion(discussion: Discussion): void
getDiscussions(): Discussion[]

// Template submissions
saveTemplate(template: Template): void
getTemplates(): Template[]

// Code reviews
saveReview(review: Review): void
getReviews(templateId?: string): Review[]

// Shared projects
saveProject(project: Project): void
getProjects(): Project[]

// Deployments
saveDeployment(deployment: Deployment): void
getDeployments(): Deployment[]

Data Persistence:

  • Menggunakan localStorage untuk browser persistence
  • Data survive page refresh dan browser restart
  • Key prefix: sct_ untuk namespace isolation

๐ŸŽจ Design System

Color Palette (Neon Web3 Theme)

--primary: Cyan (#00F0FF) - Main actions
--secondary: Purple (#9D4EDD) - Secondary actions
--accent: Pink (#FF006E) - Highlights
--background: Dark (#0A0A0F) - App background
--foreground: White (#FFFFFF) - Text
--border: Neon Blue (#00F0FF33) - Borders

Typography

  • Headings: Geist (Modern sans-serif)
  • Code: Geist Mono (Monospace)
  • Body: Default system fonts

UI Components

  • Framework: shadcn/ui
  • Icons: Lucide React
  • Animations: Tailwind transitions
  • Responsive: Mobile-first approach

๐Ÿ” Security Considerations

Wallet Security

  • Never request private keys
  • All transactions require user confirmation
  • Clear gas fee display before confirmation
  • Network verification before deployment

Smart Contract Security

  • Templates provided as-is (user responsibility)
  • Recommend audit before mainnet deployment
  • Test on testnet first (Sepolia/Base Sepolia)
  • Display security warnings for high-value contracts

Data Privacy

  • No personal data collection
  • Wallet addresses only stored locally
  • IPFS metadata is public by design
  • Community data encrypted in localStorage

๐Ÿš€ Deployment Checklist

Before Publishing:

โœ… Environment Variables (Optional for enhanced features):

# Pinata IPFS (Optional - fallback to localStorage if not set)
NEXT_PUBLIC_PINATA_API_KEY=your_api_key
NEXT_PUBLIC_PINATA_SECRET_KEY=your_secret_key

# Blockchain RPC (Optional - uses public RPCs by default)
NEXT_PUBLIC_BASE_RPC=https://mainnet.base.org
NEXT_PUBLIC_SEPOLIA_RPC=https://rpc.sepolia.org

โœ… Build Verification:

  • TypeScript compilation passes
  • No ESLint errors
  • All imports resolved
  • Build completes successfully

โœ… Functionality Tests:

  • Wallet connection works
  • Network switching functional
  • Template preview displays correctly
  • Code export (copy/download) works
  • Deployment flow completes
  • Community modals save data
  • IPFS upload (with fallback)
  • Transaction tracking

โœ… Browser Compatibility:

  • Chrome/Edge (Recommended)
  • Firefox
  • Safari (Limited MetaMask support)
  • Brave (Full support)

โœ… Responsive Design:

  • Desktop (1920px+)
  • Laptop (1024px-1920px)
  • Tablet (768px-1024px)
  • Mobile (320px-768px)

๐Ÿ“ฑ User Guide (Quick Start)

Bahasa Indonesia:

1. Menjelajahi Template

  • Buka aplikasi โ†’ Lihat 21+ template smart contract
  • Filter berdasarkan kategori (NFT, DeFi, DAO, dll)
  • Klik "Preview" untuk melihat fungsi contract
  • Klik "View Code" untuk melihat source code lengkap

2. Deploy Smart Contract

  • Pilih template yang diinginkan
  • Klik "Deploy to Blockchain"
  • Connect MetaMask wallet
  • Pilih network (Base Mainnet untuk produksi, Sepolia untuk testing)
  • Review estimasi gas fees
  • Confirm transaction di MetaMask
  • Tunggu konfirmasi (biasanya 15-30 detik)
  • Copy contract address atau view di block explorer

3. Berpartisipasi di Community

  • Navigasi ke "Community" tab
  • Start Discussion: Post pertanyaan atau tips
  • Submit Template: Upload template smart contract milik Anda
  • Review Code: Berikan rating dan feedback
  • Share Project: Showcase hasil deployment Anda

4. Export Template

  • Klik "View Code" pada template
  • Pilih export method:
    • Copy: Salin ke clipboard
    • Download: Download sebagai .sol file
    • IPFS: Upload ke IPFS dan dapatkan hash

English:

1. Browse Templates

  • Open app โ†’ View 21+ smart contract templates
  • Filter by category (NFT, DeFi, DAO, etc.)
  • Click "Preview" to see contract functionality
  • Click "View Code" to view full source code

2. Deploy Smart Contract

  • Select desired template
  • Click "Deploy to Blockchain"
  • Connect MetaMask wallet
  • Choose network (Base Mainnet for production, Sepolia for testing)
  • Review gas fee estimate
  • Confirm transaction in MetaMask
  • Wait for confirmation (typically 15-30 seconds)
  • Copy contract address or view on block explorer

3. Community Participation

  • Navigate to "Community" tab
  • Start Discussion: Post questions or tips
  • Submit Template: Upload your own smart contract template
  • Review Code: Give ratings and feedback
  • Share Project: Showcase your deployments

4. Export Template

  • Click "View Code" on template
  • Choose export method:
    • Copy: Copy to clipboard
    • Download: Download as .sol file
    • IPFS: Upload to IPFS and get hash

๐Ÿ› Troubleshooting

Common Issues & Solutions:

1. MetaMask Not Connecting

Problem: "Connect Wallet" tidak response
Solution: 
  - Refresh halaman
  - Check MetaMask extension terpasang
  - Unlock MetaMask wallet
  - Coba browser lain (Chrome/Brave recommended)

2. Transaction Failed

Problem: Deployment gagal dengan error
Solution:
  - Check saldo ETH/token cukup untuk gas
  - Switch ke network yang benar
  - Increase gas limit jika perlu
  - Coba lagi setelah beberapa menit (network congestion)

3. IPFS Upload Failed

Problem: Template tidak tersimpan ke IPFS
Solution:
  - Check Pinata API keys di environment variables
  - Fallback: Data tersimpan di localStorage
  - Verify internet connection
  - File size < 10MB

4. Network Switch Failed

Problem: Tidak bisa ganti network
Solution:
  - Ganti network manual di MetaMask
  - Ensure network sudah ditambahkan di MetaMask
  - Untuk Base: Tambahkan via Chainlist.org

5. Template Not Displaying

Problem: Template cards kosong
Solution:
  - Hard refresh (Ctrl+Shift+R)
  - Clear browser cache
  - Check console untuk errors
  - Verify JavaScript enabled

๐Ÿ”ฎ Future Enhancements (Roadmap)

Phase 4: Advanced Features

  • Template versioning system
  • Contract testing sandbox
  • Multi-sig deployment support
  • Gas optimization analyzer
  • Template marketplace (buy/sell)

Phase 5: Social Features

  • User profiles with reputation
  • Template favorites/bookmarks
  • Follow other developers
  • Notifications system
  • Collaboration tools

Phase 6: Developer Tools

  • Built-in Solidity editor
  • Contract testing framework
  • Automated security scanning
  • CI/CD integration
  • SDK for programmatic access

Phase 7: Enterprise Features

  • Private template repositories
  • Team collaboration spaces
  • Custom branding options
  • SLA guarantees
  • Dedicated support

๐Ÿ“ž Support & Resources

Official Links

Community

  • Start discussion di Community Hub
  • Share your deployments
  • Submit templates for review

Technical Support

  • Check Troubleshooting section above
  • Review console errors (F12)
  • Test on different browsers
  • Verify MetaMask setup

๐Ÿ“„ License & Credits

Technologies Used

  • Framework: Next.js 15+ (React 19)
  • Blockchain: ethers.js v6, wagmi
  • Storage: Pinata SDK (IPFS)
  • UI: shadcn/ui, Tailwind CSS
  • Icons: Lucide React

Smart Contract Templates

  • Templates provided as educational resources
  • Use at your own risk
  • Audit before mainnet deployment
  • No warranty or liability

Platform Credits

  • Built by: STC (Smart Tourism Chain) Ecosystem
  • Platform: SCT by STC
  • Version: 1.0.0
  • Last Updated: 2025-08-10

About

Smart Contract Templates by STC

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages