Script TV
A decentralized Watch-to-Earn streaming platform with mutable NFT glasses and multi-chain synchronization.
Architecture Overview
A multi-chain event-driven system. A NestJS backend listens to events on BSC and Script Network to sync state, while a Dynamic Metadata Engine patches S3 JSON files to reflect NFT leveling.
The Challenges
Problem
Standard NFTs are static (IPFS). We needed 'Glasses' that could Level Up, change rarity, and degrade in real-time based on usage. Waiting for blockchain transactions to update metadata for every minute watched was impossible.
Solution
Built a 'Dynamic Metadata Pipeline' on AWS S3. The backend tracks game state (XP, Durability). When a significant threshold is crossed (e.g., Level Up), the system programmatically patches the specific JSON metadata file on S3. This allows the NFT marketplace to reflect the new 'Level 5' stats immediately without a gas-heavy on-chain transaction.
utils.service.ts
Problem
Users could fake 'Watch Time' API calls to drain the rewards pool without actually watching content.
Solution
Implemented ECDSA Server-Signed payloads. Critical actions (Claim Reward, Upgrade Glass) require a cryptographic signature from the backend. The backend only issues this signature after verifying the video player's heartbeat and ad-impression events, ensuring the user actually consumed the content.
ScriptTV.sol
Problem
Users could hold assets on BSC (Binance Smart Chain) or the native Script Network. The app needed a unified view of their inventory across both chains.
Solution
Deployed a dual-provider WebSocket Gateway. It subscribes to `Transfer` and `Mint` events on both chains simultaneously. An idempotent handler updates the MongoDB user record, ensuring that if a user buys a glass on BSC, it appears in their Script TV app inventory instantly.
app.gateway.ts