{"id":24386057,"url":"https://github.com/zntb/nextjs-web3-simple-prediction-market","last_synced_at":"2026-04-13T15:33:34.464Z","repository":{"id":271979420,"uuid":"914801954","full_name":"zntb/nextjs-web3-simple-prediction-market","owner":"zntb","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-15T20:25:11.000Z","size":439,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T01:36:20.460Z","etag":null,"topics":["ethersjs","nextjs","shadcn-ui","solidity","tailwindcss","thirdweb","typescript"],"latest_commit_sha":null,"homepage":"https://nextjs-web3-simple-prediction-market.vercel.app","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zntb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-10T10:35:33.000Z","updated_at":"2025-12-15T20:25:13.000Z","dependencies_parsed_at":"2025-01-19T11:30:58.750Z","dependency_job_id":null,"html_url":"https://github.com/zntb/nextjs-web3-simple-prediction-market","commit_stats":null,"previous_names":["zntb/nextjs-web3-simple-prediction-market"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zntb/nextjs-web3-simple-prediction-market","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zntb%2Fnextjs-web3-simple-prediction-market","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zntb%2Fnextjs-web3-simple-prediction-market/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zntb%2Fnextjs-web3-simple-prediction-market/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zntb%2Fnextjs-web3-simple-prediction-market/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zntb","download_url":"https://codeload.github.com/zntb/nextjs-web3-simple-prediction-market/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zntb%2Fnextjs-web3-simple-prediction-market/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31759492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethersjs","nextjs","shadcn-ui","solidity","tailwindcss","thirdweb","typescript"],"created_at":"2025-01-19T11:30:29.939Z","updated_at":"2026-04-13T15:33:34.432Z","avatar_url":"https://github.com/zntb.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Prediction Market\n\nA decentralized prediction market platform built on Ethereum that allows users to bet on binary outcomes using ERC20 tokens. Built with Next.js, TypeScript, Thirdweb, and Solidity.\n\n![Prediction Market Banner](public/pm.jpeg)\n\n## 🚀 Features\n\n- **Create Markets**: Set up prediction markets with two possible outcomes\n- **Buy Shares**: Purchase shares representing your belief in an outcome\n- **Automated Market Making**: Dynamic share pricing based on total holdings\n- **Claim Winnings**: Winners receive their stake plus a proportional share of losing bets\n- **Multi-tab Interface**: View active, pending, and resolved markets\n- **Web3 Integration**: Connect wallet with account abstraction support\n- **Token Faucet**: Claim test tokens to participate in markets\n\n## 🛠️ Tech Stack\n\n### Frontend\n- **Next.js 15**: React framework with App Router\n- **TypeScript**: Type-safe development\n- **Thirdweb SDK**: Web3 integration and wallet management\n- **shadcn/ui**: Beautiful UI components built on Radix UI\n- **Tailwind CSS**: Utility-first styling\n\n### Smart Contracts\n- **Solidity**: Smart contract development\n- **Foundry**: Testing and deployment framework\n- **OpenZeppelin**: Secure contract standards\n\n### Blockchain\n- **Sepolia Testnet**: Ethereum test network\n- **ERC20 Token**: Custom prediction token (PMT)\n\n## 📋 Prerequisites\n\n- Node.js 18+ and npm/yarn\n- MetaMask or compatible Web3 wallet\n- Sepolia testnet ETH (for gas fees)\n\n## 🔧 Installation\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/zntb/nextjs-web3-simple-prediction-market.git\ncd nextjs-web3-simple-prediction-market\n```\n\n### 2. Install Dependencies\n\n```bash\nnpm install\n```\n\n### 3. Environment Setup\n\nCreate a `.env.local` file in the root directory:\n\n```env\nNEXT_PUBLIC_THIRDWEB_CLIENT_ID=your_thirdweb_client_id\n\n# Backend API variables\nRPC_URL=https://sepolia.infura.io/v3/your_infura_key\nPRIVATE_KEY=your_wallet_private_key\nTOKEN_ADDRESS=0x1Cc10F13Ea489ea3184D397196c892B148e0478C\n```\n\n**Get your Thirdweb Client ID:**\n1. Visit [Thirdweb Dashboard](https://thirdweb.com/dashboard)\n2. Create a new project\n3. Copy your Client ID\n\n### 4. Run Development Server\n\n```bash\nnpm run dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) to view the application.\n\n## 📝 Smart Contract Deployment\n\nThe contracts are located in the `pmcontract` directory.\n\n### Deploy with Foundry\n\n```bash\ncd pmcontract\nforge build\nforge test\nnpx thirdweb deploy\n```\n\n### Contract Addresses (Sepolia)\n\n- **Prediction Market**: `0x565fBDEBa409Cdf03EeC311eB96be3FDBF3e67D8`\n- **Prediction Token (PMT)**: `0x1Cc10F13Ea489ea3184D397196c892B148e0478C`\n\n## 🎮 How to Use\n\n### For Users\n\n1. **Connect Wallet**: Click \"Sign In\" to connect via in-app wallet\n2. **Claim Tokens**: Get free PMT tokens from the faucet\n3. **Browse Markets**: View active prediction markets\n4. **Buy Shares**: Select an outcome and purchase shares\n5. **Claim Winnings**: After resolution, claim your rewards\n\n### For Market Creators (Owner Only)\n\nMarkets can be created by calling the `createMarket` function on the smart contract:\n\n```solidity\ncreateMarket(\n    \"Will ETH reach $5000 by 2025?\",\n    \"Yes\",\n    \"No\",\n    7 days\n)\n```\n\n## 🏗️ Project Structure\n\n```\n├── src/\n│   ├── app/\n│   │   ├── api/claimToken/    # Token faucet API\n│   │   ├── layout.tsx\n│   │   └── page.tsx\n│   ├── components/\n│   │   ├── ui/                # shadcn/ui components\n│   │   ├── enhanced-prediction-market-dashboard.tsx\n│   │   ├── marketCard.tsx\n│   │   ├── market-buy-interface.tsx\n│   │   ├── market-resolved.tsx\n│   │   └── navbar.tsx\n│   ├── constants/\n│   │   ├── contract.ts        # Contract addresses\n│   │   └── tokenAbi.json\n│   └── lib/utils.ts\n├── pmcontract/\n│   └── src/\n│       └── SimplePredictionMarket.sol\n└── public/\n```\n\n## 🔐 Smart Contract Details\n\n### SimplePredictionMarket.sol\n\nKey functions:\n\n- `createMarket()`: Create a new prediction market\n- `buyShares()`: Purchase shares for an outcome\n- `resolveMarket()`: Set the winning outcome (owner only)\n- `claimWinnings()`: Claim rewards for winning bets\n- `getMarketInfo()`: Retrieve market details\n- `getSharesBalance()`: Check user's share balance\n\n### Reward Calculation\n\nWinners receive:\n```\nwinnings = userShares + (userShares × losingShares / winningShares)\n```\n\nThis ensures:\n- You get your original stake back\n- Plus a proportional share of all losing bets\n\n## 🧪 Testing\n\n```bash\n# Frontend tests\nnpm run test\n\n# Smart contract tests\ncd pmcontract\nforge test\n```\n\n## 🚀 Deployment\n\n### Frontend (Vercel)\n\n```bash\nnpm run build\n# Deploy to Vercel or your preferred platform\n```\n\n### Smart Contracts\n\n```bash\ncd pmcontract\nnpx thirdweb deploy\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🔗 Links\n\n- **Live Demo**: [Add your deployment URL]\n- **Documentation**: [Add documentation link]\n- **Discord**: [Add community link]\n\n## 🙏 Acknowledgments\n\n- [Thirdweb](https://thirdweb.com/) for Web3 infrastructure\n- [shadcn/ui](https://ui.shadcn.com/) for UI components\n- [OpenZeppelin](https://openzeppelin.com/) for secure contracts\n\n## 📧 Contact\n\nYour Name - [@yourusername](https://twitter.com/yourusername)\n\nProject Link: [https://github.com/zntb/nextjs-web3-simple-prediction-market](https://github.com/zntb/nextjs-web3-simple-prediction-market)\n\n---\n\n**⚠️ Disclaimer**: This is a demonstration project for educational purposes. Do not use in production without proper auditing and security reviews.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzntb%2Fnextjs-web3-simple-prediction-market","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzntb%2Fnextjs-web3-simple-prediction-market","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzntb%2Fnextjs-web3-simple-prediction-market/lists"}