Back to All Episodes
Season 2Episode 90

Safeshift

November 4, 2023
29m
2 Guests

Listen Now

About This Episode

In this episode of DevNTell, Narb welcomes hackathon pros Sahil Kakwani and Umang Patel to showcase SafeShift, their winning project from the Phala Network hackathon. SafeShift is a decentralized content moderation tool designed to prevent explicit (NSFW) content from being uploaded to Web3 social networks like Lens Protocol. The guests explain how the platform leverages Phala's fat contracts and off-chain computation to screen text and images through code-driven logic rather than human intervention. They provide a high-level overview of the architecture, including the use of TensorFlow.js and NSFWJS for image analysis, and demonstrate the app's functionality. The session concludes with a discussion of their future roadmap, which includes video support and integration with additional social protocols like Bluesky and Farcaster.

Key Takeaways

1

SafeShift addresses the challenge of content moderation in decentralized social networks where censorship resistance can sometimes lead to the spread of explicit material.

2

The project uses Phala Network's 'fat contracts' to perform off-chain computations, allowing for verifiable, decentralized moderation logic.

3

Text moderation is handled directly within Rust-based fat contracts, while image moderation utilizes a Node.js backend with TensorFlow.js and NSFWJS libraries.

4

SafeShift aims to foster a safer Web3 community by providing a code-driven middle layer for content screening before it reaches social protocols.

5

The future roadmap for SafeShift includes adding support for video content, migrating to Lens V2, and expanding to other decentralized networks like Bluesky and Farcaster.

6

SafeShift is open-source, and the developers encourage community contributions via their GitHub repository.

Featured Guests

UP

Umang Patel

Founder of LensPlay

LensPlay
SK

Sahil Kakwani

Founder of LensPlay

LensPlay

Episode Transcript

Narb

All right, we're live. GM everybody. Welcome to what's going to be another great DevNTell. So if you didn't know, DevNTell is a 30-minute window for builders to showcase something they're passionate about or been working on in Web3. This could be an awesome project you've been working on, demonstrating unit testing best practices, automation goodies, smart contracts, how to structure a project, etc. Basically you've got a passion for something, this is your opportunity to share with the community. And today I'm ecstatic to have hackathon pros Umang and Sahil on, who are going to be demonstrating to us one of their many hackathon projects called SafeShift. Welcome boys. Happy to have you on.

Sahil Kakwani

Thanks, Narb. Thanks for inviting us.

Umang Patel

Pleasure to be here.

Narb

Yeah, it's a pleasure having both of you on. I guess before we get started with the presentation, would you both like to give a brief introduction about yourselves?

Umang Patel

Sure. Umang you can start. Okay. So hi guys, my name is Umang, and I build apps and I'm a mobile developer at LensPlay. So LensPlay is a decentralized video sharing platform, a mobile-first application. And we are live on App Store and Google Play Store with more than 1000 plus downloads in less than two months. And I'm a mobile developer there. I build all the front-end stuff and all. And I'm really passionate about building projects during hackathons. And yeah, that's it. We have been building like, it's been two years we, me and Sahil are teaming up and building few projects. And yes, Sahil just won a hackathon just now. So a big congrats to her.

Sahil Kakwani

Thanks, Umang, thanks. So a short introduction about me. So I'm Sahil and I'm an hackathon enthusiast. I participate in hackathons a lot. I came into Ethereum ecosystem maybe around one and a half years back because of another friend of ours. And since then I've like never looked back. Me, Umang and other other friends we participate in hackathons regularly, try to learn something from them. And I've been a full-stack Web3 developer. I write smart contracts, I write full-stack development. So yeah, that's it about me.

Narb

Awesome. So yeah, obviously you both are very well-versed in hackathons and you guys built SafeShift, I believe it's called, for the last Phala DevNTell hackathon. I guess in the interest of time, let's get right into the meat of the presentation so we can see what's what.

Sahil Kakwani

Sure, I'll present my screen.

Narb

I think it's visible right now? It's coming up. Okay. It shows as loading for me. Oh, there you go. Okay, now you're good. You're good now. Yep.

Sahil Kakwani

It's full screen, right? Yes, yep.

Sahil Kakwani

Yeah. So hello GM guys, my name is Sahil and I'm here to present SafeShift, which is an NSFW-resistant content uploader that we actually built during the Phala hackathon that was organized by Developer DAO. So first getting, first before talking about the project, let us give a background check to what we're actually building and why we're building it. So first of all, you must have come across a lot of social media protocols and they might even be part now a regular part of your life like Facebook, Instagram, all of this where you actually share everything about your life to different people from around the world. So these protocols have actually doing good but there are certain problems that are associated with them.

Sahil Kakwani

Is it visible still? Yes. Yes. Yeah. Yeah. So there are certain issues that have popped out in the past few years and like content ownership. So basically content ownership means that whatever content that you upload to these social networks like videos to YouTube, that they're not really owned by you basically because they are stored on the servers that are owned...

Narb

Ah, that's a shame. I think Sahil is having some network issues.

Umang Patel

Okay. Let's do one thing. I will present my screen and then Sahil can just explain the stuff on a... just wait for... Hello. Sahil, let's do one thing. I will present my screen and you go on explaining it, okay? Sure, no issues. Okay. Is it visible now? Yes. Yep. Okay. So...

Sahil Kakwani

Yes. Yeah. So the second was interoperability where these networks weren't really communicating with each other. All of them had their own centralized backend that were isolated. Like you might feel that Facebook and Instagram in some ways are connected basically just because they belong to the same organization but what about different protocols of different organizations? So that is another big issue. The third and the biggest issue that we actually want to focus on is content moderation. So a lot of times in past there have been certain scenarios where these people trying to control the people who use it, like they actually ban anyone on their own like if they find something that's inappropriate to them, they'll try to ban them and there have been certain scenarios of that in past too. So this is something that's one of the biggest problems. So then came decentralized social networks which actually solved and somehow solved a bunch of all of these problems like for example Lens and Bluesky.

Sahil Kakwani

So basically the idea behind decentralized social networks is to have community owning everything that gets uploaded onto the platform and the decisions are taken based on votes that are actually undertaken by the whole community, like major portion of the community. So because of this, the people will have greater control over their data, they'll have privacy, the things would be open source and but like the big issue that pops up from this is again the centralized... the resistance to censorship because now you can't really censor anybody that easily because everything is open. The people who had come up with this idea of having these social networks actually thought about it as in a good way but there were some bad... there could be some bad people in the world who could upload anything that they want to these protocols which is harming to a lot of people out there. For example, you might have if you used any of these applications you must have randomly come across some of this disturbing posts anytime like I've seen that bunch of times and that was the thing that led us to build SafeShift.

Sahil Kakwani

So the problem that we are trying to solve with SafeShift is to have code-driven censorship resistance where everything that gets uploaded to these social networks gets checked by a decentralized code that has been stored on any sort of blockchain. So because of that everything gets verified and you have a middle layer where you actually check that everything is safe for the community to watch.

Sahil Kakwani

So with SafeShift we are actually focusing on a bunch of different things. One is to make sure it's decentralized so that it's verifiable, it's actually not really controlled by a single entity. We actually want to make sure that content gets moderated through code rather than through humans. Other than that we want to make sure that we foster a safe and secure community where everybody is safe to integrate with any of these protocols. We'll be integrating different Web3 social protocols right away with the app so that every time you upload anything through the interface, it gets uploaded to any of the social network. Currently we support Lens Protocol for that. And we'll be making sure that content gets uploaded is NSFW-resistant so that it's safe for everyone.

Sahil Kakwani

So this is a high-level architecture of what we are doing. So in the backend what we are leveraging is Phala. So we are leveraging Phala's blockchain to deploy a few fat contracts where we've written the logic to decide whether something is safer for community or not. Currently we support two channels, that is one is text so you'll be able to process text through it and another is image. Text basically is pretty simple so we'll check in the Rust contract itself, in the fat contract itself whether something is NSFW or whether it has some sort of explicit element or not and based on that we'll warn the user or otherwise if it's appropriate we'll go ahead and upload it to any of the social network, right now we support Lens so we'll upload it to Lens. The other thing that we use is image that we have right now that integrated into our interface where we are actually calling a backend Node.js server that processes that image using packages like TensorFlow.js and then uses packages like NSFWJS to train a model and classify that image, that processed image and based on that gets us a result whether the image is appropriate to upload to any of the social protocols or not. So that's a simple basically our architecture of what goes behind the scenes.

Sahil Kakwani

So this is a future roadmap. We are looking forward to do a bunch of different changes to our app. First is to have a video support to the platform so anybody would be able to get their videos and upload it to Lens Protocol right now or maybe to another social protocols itself in the future. Second thing that we are brainstorming on is to get Lens V2 support because Lens have recently migrated to V2, at least for testnet they've actually shifted and the V1 support has ended. So we are thinking about integrating to that too. And third thing is to have different social protocols right away through a single interface, so maybe a user can go ahead and choose to upload it to Lens Protocol or maybe he wants to do it to Bluesky, he can do that too or maybe it's Farcaster. So anything would be possible right away.

Sahil Kakwani

So yeah, so we are the two guys behind it. I'm Sahil and as you saw like Umang, we are the two guys building it. We've built this project during the Phala and Developer DAO hackathon. This was actually my second hackathon in Developer DAO and we managed to win it, thankful to the whole team behind organizing it. And these are the bunch of links that you can try it out to use the app. We have a GitHub repo, you can open that, Umang.

Sahil Kakwani

So basically if you are an open-source enthusiast or you want to contribute to this project you can directly go to this link and start contributing. It would be any of issues or any sort of change you want to make. So we've got this the front-end interface is hosted over here. If you can scroll Umang, I can show them the scroll to the bottom, the bottom most. Yeah. So basically there are two other repos that we are actually using. The backend repo to process the images as well as the fat contract that we are using to actually process this logic off-chain. Yeah. Okay. So that is it. Now if you can Umang, you can present the demo.

Umang Patel

Sure. So am I audible, right? Yeah. Okay. So this is the platform that we have built. So just to as Sahil said, just to get things started, I will connect my wallet first. So on clicking here, I will just connect my Rainbow wallet. It will ask me to connect it and I think it shows just to login also. So hope there's some issue over here. Okay. So we have entered the main screen here. So what you can actually do is you can just directly post the text directly on the Lens Protocol but if some explicit content is there in your text, so it would not allow me to just simply post it because we are running some algorithms to avoid it off-chain. So for example, I am typing "explicit content". So if I try to post it, okay see, I am getting a toaster which says that this content is explicit. Actually Lens is on V2, Lens has just shifted on to V2, so if I tried... if I try posting some normal stuff, it will allow me to post it but as I said that Lens has recently moved to the V2 itself. So even if this check is passed, there will be some error posting it because currently Lens V2 does not... there's some error in having rights on Lens. So we have talked with the developer team over there and we will fix it as soon as we get the response from there. And second thing is we have is the image section. Like we assure you that this thing works perfectly fine but to just for the sake of like just for the moderation stuff and all we will won't test this stuff, like we won't upload any explicit content itself. So but if I try uploading a normal image it will upload it but as I said the rights on the Lens are currently not working due to some issues in V2. But it worked perfectly fine when it was during the V1. So yeah, that's SafeShift.

Narb

Awesome. And unfortunately, Sahil I think has network issues and dropped off again but... But I guess in the meantime while we wait for Sahil to come back, so the idea is that the so that frontend is basically a means for a person to post on Lens but with the added security feature of screening the content for explicit content before you even even gets to its the on-chain computations and whatnot.

Umang Patel

Yes. So basically what we do is the text content we we take it off-chain, we compute it, we run certain algorithms over there and and then it gets tagged that whether whether your content is explicit or not and then we allow or allow it likewise, that if it's tagged explicit content we won't let it to write onto the Lens. Just clean up then. And same is with images, we are using NSFWJS library for the same. Gotcha. There's a question in the crowd to show the smart contract code and where you used the Phala functions in your frontend, if you can delve into that a bit. Yeah, we can definitely show that. Umang, can you present that fat contract repo? Sure. Or you can share the link of that right away into the chat box because I'm not able to like I'm trying to post a comment but I'm not able to put it.

Narb

Yeah, I'll share... I'm sharing it right now. Okay. This is not the repo link that is asked. I have sent in the private chat. This is for the Rust contract. This is for the frontend. Okay. Cool. Awesome. I guess during the whole hackathon process or experience, what was the most challenging part in kind of getting everything to work? Was it the actual NSFW scanning or something with the smart contracts? Anything you can recall?

Sahil Kakwani

Yeah, actually the most toughest part was to like learn about Phala, like we weren't really much familiar with Phala at that time so we had we put some effort to learn, we read their docs and we got a way to deploy a contract. So we weren't able to deploy it right away to their blockchain but we reached out to few of few folks and they were very helpful. So after that we managed to put it on the chain and yeah we were able to call it. So there were two options that we can have. Either we could have wrote a Solidity smart contract that listen that Rust smart contract that was deployed to Phala blockchain but instead of that because of optimization issues we actually thought about directly calling it through an JS SDK. So basically we used that in the frontend itself. Gotcha. Gotcha. Yeah, it sounds like you guys had a great learning experience through all of that. Yeah, yeah, yeah. So we like while building LensPlay, we actually came across a lot of this content, like if you use LensPlay you you go to some specific trending section, you can see that there are certain videos that could be explicit that couldn't be safer for like anybody to see. So because of that we actually thought about building this and like it isn't still totally complete but we'll be looking forward to improving it after this.

Narb

I can see a new question. Nithin is asking about the Lens API with the Phala functions and how you used those on the frontend.

Sahil Kakwani

Okay. Okay, so we actually using their pre-deployed Oracle that they had in the docs. We actually deployed our own Oracle and then used used their JS SDK to call it from our frontend. If you want we can show that right away but it would be in this repo itself. In the frontend repo we are using that JS SDK of Phala and we are basically calling our own Oracle and that is... So you are using Oracles? Yeah. Yeah, we deployed our own Oracle. So basically... And what are the Oracles used for? Is it... basically it is used for like the basic two functions that we showcased, right? For the text and images that are actually being executed off-chain using that Oracle. Ah, I see. Gotcha. And the other option that we had was to have a Lens API... the option other option that we had was...

Narb

Sorry Sahil, I think you've broken up. We have a frozen Sahil. But yeah, so Oracles, they were used for the computation around off-chain for the for the scan basically of the content. Yeah, yeah, yes. And what Oracle technology did you use, if I may ask?

Sahil Kakwani

Like it's basically an your own, like what Phala gives you is a way to put your own define your own Oracles the way you want in Rust and you could deploy it to the chain. So that's the basic way how it works. So we actually wrote that logic in Rust and we put that on the chain and we are basically calling it. Cool. We could actually so we could actually use it as a middle layer for another source too if we want to have some sort of let's say a Solidity data source like a blockchain source or maybe a Web2 source, like we've used the our backend servers, right? So we are basically calling our backend servers for that image processing we are calling them, we are making an HTTP request off-chain from that fat contract that is being you could term it as an Oracle too and that is basically doing this stuff. So so yeah. Cool. And do you think that'll work well for the eventual video processing as well or do you think that's more intensive? Yeah, yeah, yeah. So yeah, because it was resource intensive, that is why we had to move it to a like a centralized backend source but because the transactions still are happening off-chain but eventually the computation is happening on our servers, the large part of the computation but the result is getting noticed into the chain itself. That is why it actually makes makes it for the the whole platform being decentralized. So we'll the plan is to actually integrate different libraries to process the videos into like to divide it into different frames and click like capture images from them and then process those images again using NSFWJS only and then we'll be able to flag whether a video is explicit or not.

Narb

Cool. And if viewers today are interested in picking up some open issues or just helping out to continue to build out the roadmap for SafeShift, is it just a matter of picking up an open issue on GitHub or is there a process for them to get started?

Sahil Kakwani

No, no, no such process. It's it's pretty simple, you just need to reach out any of to our official repo and yeah, or you can directly open an issue or make a pull request and we'll look after that. We'll make sure if you contributed something valuable, we'll get it merged. Awesome. And if people want to get in contact with you, whether to continue to learn about SafeShift or LensPlay or any other cool hacks you guys have done, what's the best way for them to reach out? You can connect us through Twitter or directly on Lens. I will just share my Twitter, Twitter handle.

Narb

Sure. And that information will also be on the description of the YouTube video, so if you don't catch it here in the comments, it'll also be there. And yes, unfortunately this kind of brings us to time but yeah, just want to thank you both Umang and Sahil for coming on on a busy day, I know you guys had a busy day today, and showing us your awesome hack. I think it's a great step forward to ensure we have a safer internet out there. So thank you so much for kind of bringing this to light.

Sahil Kakwani

Yeah, thanks, thanks Narb for inviting us. Thanks for all the people for coming in and yeah.

Umang Patel

Thanks, cheers.

Narb

Yes, 100%. And for all the people that did come out today, I want to share the QR code. Sorry Sahil for covering your face there. But the QR code for claiming your NFT for being a attendee today on DevNTell. So what you want to do is grab your regular QR code scanner, scan this code, and you'll have an hour and a half from now to be able to claim your NFT for being a attendee today. So again, you'll want to grab your regular QR code scanner, scan this code, fill out the form, and you will be airdropped an NFT over the next couple of days for being a attendee. And with that, I just want to wish everybody a very happy Friday, a happy weekend, and that we'll catch you back here next week. All right guys. Yeah. All the best. Cheers.

Umang Patel

All the best. Cheers.

Listen On

Share This Episode

Share on X

Watch Episodes Live!

Subscribe to our event calendar and never miss a live episode.

View Event Calendar