One Direction, musical democracy & ERC 20 tokens

In our wonderful Blockchain Partner office, we have a great sound system that can stream music around the entire place (there are three floors). Sadly, some of us still can’t understand why listening to Maitre Gims or One Direction at a very high volume is great. Quickly, it became unbearable for some. Chaos was upon us: we had to find a way to let people choose music “democratically”.

Because cryptocurrency use is sadly still not that user-friendly, some of Blockchain Partner shamelessly didn’t know very well how to use Ether or ERC 20 tokens. Wallets, MetaMask, Ethereum are not easy concepts to master even for those who work around blockchain subjects everyday. We thought choosing music that was played in our office was a good way to teach everyone how to use a wallet and a dApp. We could have designed a very functional centralized system but we thought it was an interesting use case to make people at Blockchain Partner use cryptocurrencies and Ethereum. Also, it is a good way to demonstrate the power of sidechains or other hot and upcoming scaling techs.

We created an ERC 20 token and a voting smart contract to decide on which track the sound system should stream from Spotify. Along with this, we developed a small webapp to interact with the smart contract and a blockchain listener daemon used to interact with the Spotify API when a smart contract event is triggered. When a vote is on, a slack channel is updated so that everyone can know. To complete our set-up, we connected a Raspberry Pi to our sound system and to Spotify Connect as the input to the sound system. And that’s it!

There’s quite some work to do but that way we can have the most decentralized architecture possible.

Rules are simple: everyone starts with 200 tokens, refilled each month. Each song vote lasts 5 minutes. If no side (play it or don’t play it) gathers 10 tokens before the end of the vote, the majority wins. The vote ends before its deadline as soon as one side gets 10 tokens. That would make people listen to the worst song ever pretty easily. Sadly, you can’t do it too many times. Once a vote ends, if it is successful, the proposed song is played immediately or goes to the playing queue.

We first deployed our token and voting smart contract to the Rinkeby mainnet. Everything was working fine but it was kind of frustrating for users to wait for 15 to 30 seconds for their transaction to be mined therefore their song to be played or vote to be cast. As the vote duration is short, it can be easy to miss a deadline if your transaction takes time to be mined. Rinkeby use was instructive: employees learned how to request Rinkeby ether, how to set up Metamask, how to switch networks…

Still, it was pretty deceipting to wait.

We asked ourselves how we could speed it up. The only way to do so was to use a sidechain or a self-hosted chain. While going through the alternatives, one stood up: Thundercore! We got to know how to use Thundercore (it’s really easy) and we deployed our smart contracts on the Thunder network. The only thing that’s missing is a WebSocket that we can connect to in order to listen to events triggered by our smart contracts. We had to make some changes to our webapp in order to adapt. Otherwise, it’s working great (of course we played Thunderstruck by AC/DC first followed by Imagine Dragons’ Thunder)! Some problems users have are understanding Thunder and how to connect to it by changing networks on Metamask, acquiring Thunder Tokens etc. Once the setup is done, songs are played almost instantly.

Calm has been restored around the office thanks to music-control. Peace has been found, and One Direction is played only a few times each month. Also, everyone has now a wallet properly configured and can easily make use of their setup to access dApps. Moreover, they have a basic understanding of how transactions, tokens and Ethereum work. This time again, devs @ Blockchain Partner saved the day and the ears of defenseless music lovers.

Until next time! xoxo, your favorite tech team. 🎵