$0.16269 -4.55%
XEM · 211w

NEMp3 - Using the NEM Blockchain to Buy and Sell Items Without Storing Customer Data

Written by Chris Leary (Telegram: @csleary)

In this guide I'll show you how to use the NEM API to interact with the NEM blockchain, allowing you to sell downloads without saving any customer data locally. All sales will instead be logged to the blockchain using NEM's transaction messages, allowing us the ability to retrieve customer transactions at a later date.

In this instance, I'll be using the Ruby web app framework, Sinatra, but so long as you can make GET http requests, you can use any language. That's the beauty of using a RESTful API -- it's entirely language agnostic.

Example App: NEMp3

Mainnet: Testnet: Source:

A barebones music download app. I recommend following along with the testnet NEMp3 or source on GitHub open in another tab.

The Setup

When starting new projects, it's often useful to jot the basics down to create an overview of what we're looking to achieve. For us, it boils down to these core needs and stages:

Securely link a customer ID to purchases, written to the blockchain. Check the blockchain for these purchases. Ensure the customer has paid enough. If so, give the customer their download.

For the app, I decided to split these up into a three-page user flow:

Introduction: Create a unique ID for the customer, display product details, helpful information, etc. Payment: Give the customer all the necessary information to easily and securely make a payment. Download: Check the blockchain for customer transaction(s), and either serve a download or ask the customer to make/top-up payments.

Let's take a look at each of these stages in greater detail.

1. Introduction

To begin, we have our product information, including price, format details (i.e. what the customer is actually buying), as well as details outlining the payment methods. I've also included a FAQ at the e...

Continue on
Recent news
No posts found