The Spatial Index

A general purpose visual blockchain explorer

Ryan John King
FOAM

--

All Maps courtesy © Mapbox, © OpenStreetMap

After introducing the Crypto Spatial Coordinate (CSC) standard and the Proof of Location protocol, we are happy to introduce the third element of FOAM: The Spatial Index — a general purpose visual blockchain explorer. The Spatial Index can serve as the front-end for any decentralized application that needs to visualize smart contracts on a map. The purpose of this post is to introduce the architecture and technology stack behind the Index and demonstrate its current capabilities.

Crypto-Spatial Coordinates enable the blockchain to act as an index of spatial contracts and, by extension, allow spatial contracts to be queried and displayed on the Spatial Index. As an open-source web-app, the Spatial Index is a visual UX interface that will be used to a) allow users to interact with, understand, engage with, and act on CSC contracts and to b) serve as the foundation of the large variety of decentralized applications that can be built on top of our protocols.

Architecture and Technology Stack

The spatial index is an explorer for geospatial assets on the blockchain. The full architecture of the application consists of:

1. Frontend app a visual explorer written in purescript, backed by our purescript-web3 library2. Interactive deck.gl and D3 visualization components for visualizing network activity utilizing the FOAM protocol.3. Metamask/Uport for secure transaction signing and authentication.4. REST API written in haskell, complete with swagger documentation and a haskell client library provided by the servant framework.5. Ethereum logs indexer for indexing logs produced by spatial index contracts, making them available for performant queries.

The diagram above illustrates the five major components that have been developed for the Spatial Index. Their relationships can be simplified as follows:

The indexer and database component capture all relevant data emitted by FOAM contracts via the Ethereum logs — e.g. deploying CSCs, performing localizations, token transfers, etc — and indexes it for high performance queries and consumption over websockets. The only other thing required to run this component is an Ethereum client with the web3 API enabled. While we run a custom kubernetes cluster of geth and parity nodes scaled accord to user demands, this indexer is available as a standalone docker service for other developers who want access to the underlying data in Postgres and ElasticSearch.

The REST API utilizes this data store for our applications, and also acts as an open API for other applications seeking access to data generated by FOAM. It is written in haskell using the servant framework, meaning that up-to-date API documentation and client libraries can be generated from the type system on demand.

Our visual frontend explorer displays the data from the REST API in meaningful ways using D3.js and deck.gl. In addition, the visualizer allows the user interact with FOAM contracts in the browser via Metamask or Uport. The visualizer is written in purescript, a strongly typed functional programming language targeting the browser, and is backed by our purescript-web3 library. (See our previous post on why we believe this is important.)

The main achievement and contribution of this design is allowing users to interact with the blockchain and deploy smart contracts with geospatial parameters from within a web browser. The architecture of the Spatial Index forms a smooth loop of events, from web-app, to blockchain, to indexer, and back to the app. We use some of the most advanced software available for the task, including the languages, the data processing units, and the kubernetes cluster that supports all of it.

Walkthrough of Current Skin:

1: Navigate Crypto-Spatial Coordinates

Spatially-specific smart contracts, also known as Crypto-Spatial Coordinates (CSCs) are displayed directly in the application. Users can apply filters to display CSCs according to each use-case. In our first version of the Spatial Index, the CSCs represent the Zone-anchors and their Zones as described in our previous blog post on the Proof of Location Protocol

Map courtesy of Mapbox

2: Deploy a Smart Contract

A Crypto-Spatial Coordinate is deployed as a smart contract directly via the Spatial Index by using Metamask.

Map courtesy of Mapbox

3: Visualize new smart contracts within the Spatial Index

We check when a new smart contract is deployed, and automatically visualize it in the Spatial Index. In the example below, we are using the Rinkeby Testnet.

Map courtesy of Mapbox

The Future

The current version of the Spatial Index is used to visualize our Proof of Location Protocol. But our vision for it goes far beyond that. We have designed the Spatial Index to enable a vast number of potential applications across different markets, from a UI for a decentralized Uber that empowers drivers and passengers to transact without middlemen, to a control panel for blockchain-based supply chain management, and a spatial bounty game that combines elements from Pokemon Go and CryptoKitties. We are strong believers in this ecosystem and hope that this tool will empower a new generation of decentralized spatial applications, most of which we can not even envision yet.

Map courtesy of Mapbox

We will be ramping up our ecosystem support over the coming months by sharing more documentation and resources. We look forward to seeing how the community will use and adapt the Spatial Index.

We welcome feedback from the community and are open to collaborations, so please get in touch.

--

--

Editor for

Ryan John King is the co-founder and CEO of FOAM, a spatial protocol for the Ethereum blockchain that provides secure Proof of Location services www.foam.space