DEV Community

Cover image for πŸš€ Blockchain Social Media Platform - ReactJS UI - Tips and Tricks!
ViperT
ViperT

Posted on

πŸš€ Blockchain Social Media Platform - ReactJS UI - Tips and Tricks!

Hello everyone! πŸ‘‹

How's your coding journey going so far? I hope you're doing great! My name is Matias Affolter, and I'm excited to share insights into the project I’ve been working on during 2024 and beyond.

Image description

🌍 Building a Business & Blockchain-Powered Social Media

While I love coding, I had to step away from full-time frontend development to run a business and establish a company in Switzerland. Setting up a Swiss company requires around $120,000 in capital, but the good part is that you can contribute intellectual property, such as software. That’s how my previous project, Pixa.pics, which allows users to draw pixel art on the web, became an asset for the company.

πŸ›οΈ The Blockchain Foundation

Did you ever hear about STEEM or HIVE? These blockchains were among the top 10 in 2017, some reaching a $1 billion market cap! They feature a super-fast 3-second block time and use a layer-1 distributed ledger fully governed by decentralized consensus. Inspired by high-speed transaction processing in online gaming, Dan Larimer developed Graphene, a technology capable of handling 300,000 transactions per second, surpassing Visa and Mastercard combined! 🀯

🎨 Why Store Pixel Art on the Blockchain?

A year ago, I decided to fork STEEM/HIVE and integrate on-chain pixel art storage as NFTs! Unlike most NFTs (which store only a hash), our blockchain stores the actual pixel art in Base64. This means the data remains immutable forever.

πŸ’‘ Storing 30kB of pixel art on Ethereum could cost thousands of dollarsβ€”on our fork, it’s fast and efficient! With 21 primary nodes (witnesses) ensuring redundancy, our solution can scale to millions of users. Beyond that, sharding would be necessary, but it's technically feasible.

πŸ–₯️ ReactJS UI - Essential Tips and Tricks πŸ› οΈ

I’m building the Pixagram UI in ReactJS. Here are some impactful tips for optimizing CSS, HTML, and JavaScript:

🎨 1. Homepage Animations & Graphics

Image description

βœ… Use CSS gradients and SVGs instead of raster imagesβ€”they are lightweight and scalable.
βœ… Check out the fading rainbow effect on Pixagram.io 🌈

πŸ“Έ 2. Handling Images Efficiently

Image description

βœ… Pixel art needs upscaling, not downscalingβ€”use Canvas API instead of HTML <img> for rendering.
βœ… Use react-virtualized to handle large lists of posts smoothly.
βœ… Lazy-load content with Webpack chunk splitting for better performance.

πŸ–ŒοΈ 3. Pixel Art Upscaling - WebGL & XBRZ

Image description

βœ… Hexagonal rendering engine (Canvas2D) was slowβ€”WebGL shaders are better.
βœ… XBRZ algorithm can upscale pixel art by 6x into smooth shapes without AI.
βœ… Runs in a worker thread, making it fast & deterministic.

πŸ€– 4. AI-Powered Pixel Art

Image description

βœ… We use Hugging Face AI to generate pixel art from selfies.
βœ… Color quantization ensures pixel art remains authentic & lightweight.
βœ… WebP format > PNG (smaller file size, same quality).

🎨 5. Sorting Colors Smartly

Image description

βœ… Sorting colors in RGB space requires sorting 3D vectors.
βœ… Z-order curve and Hilbert curve are optimal for sorting color palettes.

⚑ 6. CSS Performance Optimizations

Image description

βœ… Use transform and effects instead of opacity, left, or topβ€”they run on the GPU for smoother animations.
βœ… Apply contain to prevent layout recalculations and improve render performance.
βœ… will-change optimizations: Set it right before an animation starts and remove it after to avoid slowdowns.

πŸ”₯ 7. React Rendering & Hydration

Image description

βœ… Use PureComponent to prevent unnecessary re-renders.
βœ… No automatic hydrationβ€”everything is handled deterministically for better performance.

πŸš€ Final Thoughts

This project is a blend of blockchain, pixel art, and AIβ€”a unique combination that makes Pixagram an innovative platform. We’re currently working towards government approval for fundraising, and once that’s set, we’re rolling out big updates! πŸš€

Let me know what you think! Do you have other performance tricks you use in your React projects? Drop them in the comments below! πŸ’¬πŸ‘‡

Top comments (0)