This is the first of five articles about a project using RChain deployed to Raspberry Pi 3, interacting with phones in the local area over Bluetooth LE 4.  

Physical coin faucet origins: The quest for free beer

“How could we, say, give away free beers on the blockchain?”

This is the question that haunted us. How could we make it easy for a bar owner to randomly give away a beer to their customers every hour in an automated, secure, and publicly verifiable way? How could we make those free beers go to only those who were physically at the bar, with the side effect of encouraging people to stick around longer than they otherwise would have?

 

The brainstorming began. Or, more accurately, has begun. This is a multi-part blog series, a developer’s journey of sorts as we attempt to fuse blockchain with the physical, tangible world, with the ultimate magnanimous goal of enabling more free beer for everyone.

The Team

BlockSpaces, LLC is a blockchain-focused development co-work and education center based in Tampa, Florida. There are a number of freelance programmers working out of the space, so forming a development arm focused on building blockchain prototypes was a natural fit. For this project we have a team of five developers with broad experience in blockchain, full stack development, networking, and Internet of Things (IoT).

 

Chris Williams, BlockSpaces CTO, brainstormed the basic concept several years ago, at the restaurant of a local Bitcoin meetup, but never had all the pieces come together to actually attempt to build it. Until now.

The Concept

The basic concept behind the project is relatively simple: create a loyalty program of sorts that that will airdrop RChain-based digital assets to people in a given area. These digital assets could be redeemable coupons or giveaways that would be utilized in the moment or at a later date. The idea is to create a system that will encourage people to stay in an area longer than they might otherwise through business owner-defined incentivization.

The use case that birthed this idea, as we touched on earlier, evolves from the bar scene. At most establishments where adult beverages are imbibed, there is a desire to keep patrons consuming beverages at your establishment for as long as possible. What better way to do that than through a simple, secure and automated system designed to incentivize hanging out for just a bit longer?

An exploration of stack options

 

In order to build a hyper-localized “physical faucet” that will airdrop digital assets to people physically present, we need to nail down some technologies.

 

The first is the local device. We want something that is reliable, inexpensive, highly configurable, inconspicuous, and has enough horsepower to run RNode while simultaneously dealing with the connectivity issue of dozens of users coming and going from the location. The device that is most likely to fit the bill is the Raspberry Pi 3. With a quad core processor, 1GB RAM, dual-band wireless and Bluetooth for under $50, it’s our natural first stop. We are currently looking at Bluetooth BLE as a potential means of determining physical presence. This is still in the testing and research phase, so we should have more info on the process in a future post.

 

We’re also going to need a web service where an owner will be able to configure their RChain airdrops. We have a few Python devs on the team, so a Python Flask-based backend is on the table, but we also have JavaScript developers on the team, so Node.js with Express and CouchDB for storage is also being considered. Weighing on the decision is performance and Pi support, but also we’re attempting to blaze some new ground for future RChain developers, so broadly familiar stacks that can meet our needs will have a head start in the final decision.

 

Finally, the end mobile user experience has to be as seamless and effortless as possible to encourage actual, real world adoption. At the moment we are leaning toward a React Native solution. Conceptually, we have already discovered a few potential friction points, especially for first-time users of the system (Bluetooth BLE, for example, requires a user to have Bluetooth turned on and discoverable.) Our new user onboarding process and RChain integration will be just a couple of the challenges we are bound to face in this journey.

Why RChain?

There are any number of blockchain solutions this could be built on, but for those of us looking to build the decentralized future, RChain offers the best of both worlds: true decentralization and ridiculously fast and scalable transaction throughput. The fact that Rholang smart contracts can actually be proven to work correctly is a selling point for anyone familiar with the smart contract disasters of yesteryear.

 

In truth, the Rholang contract is a relatively small (albeit critical) portion of the work that needs to be done to deliver on our Proof-of-Concept. However, at the start of this project no one on the Project Sandcastle team is yet familiar with Pi Calculus, Rho Calculus or Rholang, so we’re anticipating a learning curve in its implementation. We hope to document the experience to help onboard new RChain developers and to highlight any potential road bumps along the way.

What’s next…

In addition to some pretty relentless brainstorming, we’ll be running experiments and prototyping on the Raspberry Pi over the next few weeks, playing around with its bluetooth connectivity, and finalizing our technology stack. You can read Part 2 here.

 

This project is a collaboration between BlockSpaces, LLC and RChain Cooperative

Code is open source and available on https://github.com/BlockSpaces-devops/sandcastle