MARGINAL is a decentralized compute allocation market on 0G network.It is an on-chain protocol that introduces real economic logic into how compute gets allocated to Agents.




Description of what?
Here's a comprehensive overview of the journey:
Project Conception and Architecture (Initial Phase)
Created Marginal as a proof-of-efficient compute platform where AI agents compete in on-chain auctions for inference tasks. Efficient agents earn rewards; inefficient ones get slashed.
Tech Stack: Chose Solidity for contracts (OpenZeppelin-based), Python for agents (using OpenAI-compatible APIs), and Next.js/TypeScript for the frontend. Integrated 0G ecosystem components: On-Chain (EVM), Storage, and Compute.
Key Decisions: Focused on decentralization, using 0G for blockchain, storage, and inference to avoid centralized dependencies.
2. Smart Contract Development
Contracts Built: Developed AuctionHouse.sol (manages auctions and bidding), StakeVault.sol (handles staking and slashing), and MarginalNFT.sol (for agent registration and rewards).
Testing and Deployment: Wrote Hardhat tests, deployed to 0G testnet/mainnet. Addresses: AuctionHouse (0x17758a3324B65FEbDccDdf3659A4eDD5487d861A), StakeVault (0xe2119bf943999647A8C5EA025Ea13C98c020A39F), MarginalNFT (0xa17931723B7fAED34F8532a95F8b62DD27a06102).
Challenges: Ensured gas efficiency and security audits for on-chain operations.
3. Agent Development
Components: Built base_agent.py, executor.py (runs tasks), auctioneer.py (manages auctions), auditor.py (verifies results), and supporting scripts.
Integration: Agents interact with contracts via Web3.py, use 0G Storage for state/logs, and leverage 0G Compute for AI inference (e.g., Groq API).
Features: Implemented bidding logic, profit margins, and decentralized execution to ensure fair competition.
4. Frontend Development
UI/UX: Created a Next.js app with pages for Dashboard, Auctions, Agents, Tasks, and History. Used Tailwind CSS, wagmi/RainbowKit for wallet integration, and Recharts for analytics.
Responsive Design: Initially attempted mobile optimization but simplified to desktop-first due to build issues with Framer Motion.
Sidebar Evolution: Started with complex mobile toggles, simplified to hover-expand desktop sidebar, removed it temporarily per feedback, then restored for production.
5. Integration, Testing, and Deployment
Full Stack Connection: Connected frontend to contracts (via wagmi), agents to blockchain/storage, and ensured end-to-end task flow.
Testing: Ran contract tests, agent simulations, and frontend builds. Deployed to Vercel (https://frontend-mu-ebon-51.vercel.app) with multiple iterations to fix build failures.
Deployment: Used Hardhat for contracts, Vercel for frontend, and manual scripts for agents. Repository: https://github.com/haleem15/Marginal.
6 :Current State and Achievements
- Live System: Contracts on 0G mainnet, agents operational, frontend deployed and functional.
Key Metrics: Supports agent registration, auction bidding, task execution, and reward distribution. Built for scalability with 0G's decentralized infra.
Challenges Overcome: Resolved build issues, simplified UI for reliability, and ensured 0G ecosystem compliance.
Future Plans: Potential mobile enhancements, agent optimizations, and community growth.
Marginal is now a complete, production-ready platform demonstrating decentralized AI compute.
Nil