Loading video player...
Your indexer is only as good as the events your contract emits. Most Solidity devs treat events as an afterthought. They're wrong, and it costs them every time someone asks "where's the data for our dashboard?" This video flips the perspective. We're designing a marketplace contract from the ground up to be indexer-friendly. Every event, every storage layout, every view function is shaped by one question: how does The Graph or a custom indexer consume this efficiently? The mental shift is what matters. A smart contract isn't just a state machine. It's a data source. And like any good API, it should be built with consumers in mind. Inside the build: A complete IndexableMarketplace contract under 250 lines, with NFT listings, price updates, cancellations, and sales. Standard marketplace mechanics, but every state change is engineered for downstream consumption. Rich events with maximum indexed parameters. Three indexed slots per event is free real estate that most contracts waste. We use them for sellers, collections, and listing IDs so dashboards can filter via eth_getLogs in a single call. A monotonic sequence counter that gives indexers a stable cursor independent of block.number. No more reorg anxiety. No more "did I miss an event?" Just give me everything where sequence is greater than 12345 and you're done. An aggregate Activity event with an indexed bytes32 kind. One subscription gets every state change across the contract. The pattern that makes real-time dashboards feel instant. The swap-and-pop trick for maintaining an active listings array in O(1) on removal, using an idxPlusOne mapping to distinguish "not in array" from "at index zero." Pagination-friendly views with start and count parameters so frontends never run out of gas calling unbounded arrays. Bulk read functions for backfill workers that need to fetch hundreds of records in a single RPC round-trip. Then we wire it up. A subgraph mapping example showing how mechanical the off-chain code becomes when the contract is designed properly. Reorg handling explained. The anti-patterns that secretly destroy indexer performance covered in detail: stringly-typed events, mutable IDs, missing state transitions, tx.origin everywhere. Prerequisites: intermediate Solidity. If you've written a contract that emits events, you're ready to make those events twenty times more useful. Subscribe for more deep-dive Solidity builds. 🎵 Music "Skyline Views" by ‘Spective & Erwin Do’ https://www.youtube.com/watch?v=LOykYJo9ur4 💿 Listen everywhere: https://lofihiphop.de/skylineviews ✅ For more Copyright Free Music visit: https://youtube.tamamusic.com Tags: solidity tutorial, the graph subgraph, on chain indexing, blockchain indexer, eth getlogs, solidity events, indexable smart contracts, subgraph tutorial, web3 data, ethereum events, smart contract data, defi indexing, custom indexer, solidity dashboard, smart contract development, ethereum development, web3 development, advanced solidity, ethereum smart contracts, web3 tutorial, blockchain development, solidity 0.8, graphql web3, viem watchcontractevent, marketplace contract Hashtags: #Solidity #Web3 #Ethereum #SmartContracts #TheGraph #Subgraph #BlockchainDevelopment #Web3Development #EthereumDev #SolidityTutorial #DataIndexing #SmartContractDev #CryptoDevelopment #DeFi #Web3Data