Skip to content

Instantly share code, notes, and snippets.

@frankfka

frankfka/blog.md Secret

Created September 2, 2020 02:21
Show Gist options
  • Save frankfka/411bd413dc97c984c5fac0407c5fa4c3 to your computer and use it in GitHub Desktop.
Save frankfka/411bd413dc97c984c5fac0407c5fa4c3 to your computer and use it in GitHub Desktop.

Enabling Easy Cryptocurrency Payments with PayID

One of the biggest hurdles to the adoption of cryptocurrency is the difficulty in transacting. The complex terminology, high overhead in setting up wallets, and myriad of different currencies that exist present huge challenges to mainstream crypto payments. The PayID protocol attempts to solve some of these pain-points to decrease friction in the entire process. In this blog post, I'm going to share my experience working with PayID while creating xPayments, my submission to the PayID hackathon.

What is PayID?

Want to send some USD to a friend? Open Venmo or Cash app and do it in a click.

Want to buy stuff online? Use your PayPal or credit card and pay in a few clicks.

Want to send cryptocurrency? Make sure you have a compatible currency wallet, login with your 10+ character password, then manually copy and paste a long and complex address before triple checking and sending off the payment.

The folks at PayID envisioned a payment protocol that was currency agnostic and easy to interface with. A simple, easy-to-read payment address, such as frank$jiafrank.com, contains all the payment methods and addresses that I accept - be it Bitcoin, XRP, Ethereum, or even USD.

In an ideal world, all cryptocurrency wallets would be able to take in a PayID address as input, and automatically resolve the payment addresses associated with that payment address.

You would input a simple, email-like identifier into your mobile wallet, then enter in the amount to send before pressing confirm. Or even simpler - scan a QR code - which would already encode the value of crypto to send, then simply confirm the requested amount before sending off the transaction.

As you can see, the PayID protocol enables anyone to easily send cryptocurrency (or even fiat) payments.

Great - How Does it Work?

PayID is built to support decentralization. Anyone can host their own PayID, and as long as they adhere to the protocol, any client can resolve the addresses associated with the PayID. The basic protocol is simple. A given payment address, for example frank$jiafrank.com, maps to a URL from which the address details can be retrieved.

By default, an address frank$jiafrank.com maps to the url jiafrank.com/frank.json. I can simply serve this json file, and any client would be able to retrieve it and parse it for payment details. Here's an example JSON:

https://gist.github.com/2aed4399d02fbc93764f2edd164a7fb0

The workflow for a client would be:

  • Take in the PayID, then retrieve the json file that maps to the URL associated with the PayID
  • Read the json file for a list of the payment methods

Pretty simple, but there's lots in the works, such as setting up "verified" PayID's and adding in the ability for invoicing. Interested? Check out the PayID whitepaper.

Creating a PayID

For now, PayID is in its infancy. As far as I know (and at the time of writing), only the Xumm mobile wallet supports PayID resolution. When first starting to develop with the protocol, it was difficult to figure out how to even create a PayID.

There isn't a great resource to quickly generate a PayID with an external service's domain name (I really think there should be!). So for now, your options are the following:

After setting up a PayID, you can use PayID Validator to make sure that your PayID is valid.

xPayments.me - Easy Crypto Payment Pages

Now for the cool new stuff! PayID is a protocol, meaning that it's the basis on which additional functionality can be built. I wanted to address the following pain points:

  • It's difficult to share cryptocurrency payment information - this is easily solvable using the PayID protocol
  • Most of us suffer from "registration fatigue" - getting setup should take less than a minute
  • It's difficult to create and maintain a PayID - we never got around to enabling PayID creation, but this is easily doable with a simple backend + database

xPayments.me was designed to address these shortcomings. By building on top of the PayID protocol, users can create their own "payment page" with their crypto address information in just a few seconds:

Insert image of creation page

Further, they can specify a requested amount - this is especially useful for invoicing. Let's say that I'm a freelance web developer, with a single PayID, I can create multiple payment pages for my different clients, share them through social media or email, and collect payments without needing to triple-check my payment addresses and manually coordinate payments.

When people receive the payment page link, they see something like this:

Insert image of payment page

The page would show all the payment options associated with the PayID, and the requested amount (if any). The payee can then pick and choose their payment method and send the requested amount (which is automatically converted to the currency using the latest exchange rates). Here's a complete demo:

Insert video demo

Building the initial prototype was quite pain-free. The tech stack is as follows:

  • Vue.js front-end (Repo)
  • Node.js back-end (Repo) + MongoDB Atlas as a database

We used the Xpring-JS library to interface with PayID - this helped to abstract away the nitty gritty details of working with the PayID protocol directly. This POC turned out pretty well, but is not meant at all for production use.

That being said - I haven't seen something like this being offered as a production service just yet. So if anyone is interested in collaborating to polish up the project and offer it as a service, feel free to reach out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment