Building on top of my idea for one-page checkout with Money Button , I have been brainstorming over the past few weeks how to sell one-time digital use codes on-chain.

Sympathizing with _unwriter's efforts to reduce the need for application developers needing to rely on servers, I want to achieve this in order to eliminate the costs that come with hosting one.

Additionally, I want to solve the issue of being notified once I receive payment - again without needing to rely on my own server. I can do this leveraging the memo protocol .

In the Money Button swipe - I add an OP_RETURN message that replies to a transaction I have on memo where I simply ask "Did someone purchase my download code?"

Since I receive smartphone notifications via the Android Memo app, I am notified immediately when a customer purchases the digital content.

The next issue I wanted to solve was implementing a one-time use Money Button on-chain but again without a server. After thinking through this for sometime I came up with an idea leveraging _unwriter's Planaria tool .

I can query for any type of transaction via Planaria, therefore I can implement a check if a certain type of transaction has been previously broadcast to determine if I will render the Money Button for check-out or not.

If you see the replies to my memo post perhaps you have already figured out how this is done!

Generate a unique address from your wallet (preferably unused at all before) and first query for a transaction that has that address anywhere (output address, referenced in a pushdata, etc.).

The first time this query is run, no results will be returned. In this case I render the Money Button, implying digital code is for sale.

In my implementation, I add the address I generated to be the 4th pushdata in the memo OP_RETURN I embed in the Money Button swipe.

Therefore, when I check at the beginning, I am checking if this code has been paid for already.

If it has, I will render my Money Button as disabled, with a label reading that the digital code is sold out.

With this logic, I effectively have a One-Time Checkout with Money Button implemented, on-chain.

This concept can be taken a step further to implement inventory tracking, by checking for x number of transactions with an address (or a batch number) in some part of the transaction.

Now, delivering the code to the customer in a secure manner on-chain is a larger problem. I can use bitpaste.app to actually sell my digital code behind an encrypted paywall - but I cannot modify the Money Button implemented there to condition it for one-time use.

Pinging @libitx ....

I will eventually deploy this on bitpaste.app to actually sell this download code, but do not want to deal with the case that a 2nd customer swipes the button and I have to manually refund them.

The goal of this post was to communicate how I did this, as I think it demonstrates how combining several tools others have built together in order to solve a real business use case.

Tools leveraged here: