DEV Community

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

Posted on

1

๐Ÿš€ 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! ๐Ÿ’ฌ๐Ÿ‘‡

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

๐Ÿ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someoneโ€™s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay