A crypto charity fundraising on Ethereum, with a 60KM ultra-run STRAVA GPS Oracle

Discover the technology powering Cryptorun.brussels

60KM run = release all the ETHs. That’s an offer you can’t refuse.

On the 20th of May I’ll be attempting the Cryptorun.brussels challenge to support my friends at BeCode, a great non-profit promoting tech education for all. The pitch is simple: we raise crypto on a smart contract running on the Ethereum Blockchain. The smart contract is linked to my GPS via the Strava running app. The funds are only released if I manage to run 60KM in one go. Otherwise, they’re sent back to the donors.

This article aims to offer the full technical perspective on the most interesting aspects of this challenge. A more general purpose blog article will follow soon. This timing is necessary so that friendly devs get a chance to review the smart contract before it is launched on the main net and the fundraising starts. So: geeks, enjoy!

Overall architecture

So simple, yet so exciting

The architecture consists of 2 main parts:

  • A smart contract running on the Ethereum Blockchain. A smart contract is a specific kind of application that benefits from Blockchain’s immutability, transparency and decentralisation advantages. This is great for our specific use case, where we want to prove to donors that their funds will only be released if the goal is met (60KM are run). No need for lawyers to review this all, the smart contract is responsible for its own enforcement.
  • An Oracle. To get information about the challenge status (ongoing, accomplished, failed…), the smart contract indeed needs a bridge between the Blockchain and the outside world. This is precisely the role of the Oracle. Here, it relies on information gotten from Strava, a popular running application, with a small scoring proxy atop the Strava API to ensure the data is directly consumable by the smart contract.

Let’s discuss these 2 parts in details. Note that they’re fully open-source and can be consulted on the GitHub repo of Cryptizens.io.

The smart contract

Enjoy this well-documented code below ;) This contract uses Oraclize, a wonderful service allowing Blockchain developers to directly consume data from the outside world with smart contracts. Note how we’re calling the Oracle API endpoint in the refreshChallengeStatus() function? It’s really that easy.

To all Solidity developers out there: please don’t hesitate to reach out, should you have any comments to improve this smart contract. It is still under development and will certainly benefit from all your good input to improve overall performance and safety. Thanks in advance!

Smart, eh?

The Oracle

The key component of the Oracle is an AWS Lambda serverless function that directly consumes the Strava API and exposes its proxied results via an AWS API Gateway.

The proxy is necessary so that the smart contract only gets a very simple result as input for the challenge status (just a string representing the status as ongoing, accomplished, failed…). Indeed, Solidity just isn’t evolved enough for complex data manipulation with JSON for example. The proxy also checks for the actual conditions required for the challenge to be accomplished: distance, timing and location. Again, enjoy the extensively commented code below ;)

Always trust the Oracle !

Challenges & improvements

The Cryptorun.brussels challenge specifically aims to support BeCode, but also wants to highligh everyday use cases of Blockchain. A charity fundraising is a very good example of that. However, it is important to realize that this architecture does not fully respect the immutability and decentralization principles that Blockchain adheres to. Indeed, the Oracle part is still controlled only by a few individuals:

  • The proxy is controlled by myself
  • The Strava API is under control of the Strava engineers
  • My GPS could easily be hacked, or I could upload the race result of another runner to my Strava account to fake that I accomplished the challenge

Hence we currently restrict this whole challenge to a non-profit fundraising because of the non commercial incentives at stake. But we can certainly expect that IoT and Blockchain improvements (cf. IOTA, DataBrokerDAO) will solve this in the coming years: my GPS could be authenticated and connected to the Blockchain in real-time — then there would be no way to alter the data, letting us envision even crazier schemes!

Thanks for reading and please head to Cryptizens.io if you’d like to discover other psychedelic Blockchain stuff. Cheers!

Like what you read? Give Thomas Vanderstraeten a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.