CanCan is a decentralized video-sharing social networking service that lets people stream and share videos onto their mobile device directly from the internet. The DFINITY Foundation developed the sample dapp to demonstrate the abilities of the Internet Computer, the world’s first blockchain that runs at web speed with unbounded capacity.
CanCan shows how developers can build open, decentralized apps on the Internet Computer that deliver great user experiences. It demonstrates some of the many ways that dapps can use tokenization to attract and incentivize users and other audiences, creating viral loops that deepen engagement and attract even more users. CanCan is just one example of a variety of dapps that can only be developed end-to-end on an infinitely scalable blockchain like the Internet Computer.
We’ve now made all of the source code for CanCan public, offering it to the developer community as a model to inspire the creation of open internet services on the Internet Computer. A developer going through the code will find:
- advanced Motoko features like the Motoko Package Manager Vessel;
- lots of system features like time and authorization in the API;
- integration with the Internet Identity service;
- best practices for end-to-end testing and continuous integration.
CanCan also shows how tokens can motivate users to produce, engage with, and moderate content — effectively making users members of the team that manages the dapp.
Every 24 hours, each CanCan user gets 10 “Super Likes” that they can award to videos in their feed. If a video receives enough Super Likes, it goes viral. When a video goes viral, early Super Likers collect reward points that they can later redeem for prizes. CanCan also allows users to show their appreciation to creators by sending them tips in the form of reward points. Video creators earn reward points when they upload videos, receive tips, and when their videos go viral through Super Likes.
There are even more possibilities for using tokenization to engage users and other audiences. For example, CanCan could feature periodic “Drop Days” where users redeem reward points for CanCan tokens that enable them to vote on features and functionalities, and receive rewards for their participation in governance.
CanCan can similarly incentivize users to help moderate content. In the dapp’s profile settings, users can opt in to receive newly uploaded but unmoderated content in their feed as long as they can verify that they are 18 years of age or older. When they see content that they consider inappropriate, they can flag it. If a certain threshold of other moderators flags the content as inappropriate, the user will receive reward points for having taken action.
CanCan doesn’t need a web server, content delivery network, firewall, an external database to hold state, or any of the other complexities that we’ve come to accept as inevitable in legacy software. The dapp is composed of multiple stateful modules, or “canister” smart contracts. All data is persisted simply by declaring standard data structures like arrays or maps right inside the canister.
The other challenge we gave ourselves was to make a dapp that could scale unbounded by the protocol. That meant handling millions of videos and trillions of bytes. Our first approach was a distributed hash table (DHT) based on Kademlia and implemented in Motoko. The front end would request a video from the back end, which would respond either with data directly or recursively request the data from one of its peers in the DHT.
The ability to shard and rebalance storage across multiple canisters gave us the scalability we were looking for, but we kept pushing. We were able to write CanCan without a traditional back-end API. The front end builds directly on top of the relatively simple interface of the DHT and its “get” and “put” methods. In fact, if you kept the same interface, you could completely swap out the implementation with one written in an entirely different language like a canister written in Rust — which is exactly what we did.
Every demo dapp is intended to teach people some novel concepts. As we started building more and more features, we realized that scaling was not the bigger innovation we wanted to share with people, because the biggest problem for entrepreneurs is traction first and scaling second. So we began to rewrite the back end of CanCan in Motoko around the main stories we have discussed in our Internet Computer Primer to focus on clean APIs and traction.
CanCan demonstrates how developers can build powerful open internet services end-to-end on the Internet Computer while using tokens to attract and incentivize engagement with the dapp. This is just a glimpse of what’s possible on the Internet Computer.
We look forward to seeing what you build…