paypresto BETA

The simplest way to let your users fund data transactions in your BSV app.

What is Paypresto?

Paypresto is a service for Bitcoin app developers that makes it easy for your app's users to pay for data or non-standard transactions, with any BSV wallet*.

Apps can construct any kind of transaction, from R-Puzzles and other complex scripts, to Metanet and data carrier scripts. By embedding a simple widget, your users can fund the transaction from their favourite wallet.

It's simple and secure, and allows you to get on with building your app instead of worrying about wallets and UTXO management. And because Paypresto makes use of peer-to-peer protocols, the experience for your users is as fast as ⚡️ lightning!

Want to try it out?

Want to give Paypresto a whirl? Lets have some fun and create some digital artwork to put on the blockchain. Use you mouse or finger to draw a picture, and when ready click the button to see Paypresto in action.

How do you use Paypresto?

Paypresto is a non-custodial payment service. This means you, the developer, are responsible for generating and using private keys. If something goes wrong, Paypresto provides ways to recover any UTXOs, but these are only useful if you know what private key you used when creating the payment.

In the demo above, a random single-use key is generated for each new session. In a production app, consider giving your users their own deterministic key-chain. This way you can take full advantage of the Metanet, without having to worry about implementing full wallet functionality and UTXO management.

Installing paypresto.js

Payypresto has a peer dependency on bsv and txforge. The JavaScript widget and dependencies can be installed using your preferred package manager:

npm install paypresto.js bsv txforge
# or with yarn
yarn add paypresto.js bsv txforge

Alternatively, you can use a CDN:

<script src="//"></script>
<script src="//"></script>
<script src="//"></script>

Simple, declarative API

The following example shows all that is needed to integrate Paypresto in to your site.

import {Presto, embed} from 'paypresto.js'

const payment = Presto.create({
  key: 'Kx2p4o7FYJYjEwufdYJLXjPtu2vaSpQ8mB7mjMJnaHnPSrGQ1nQk',
  description: 'My test payment',
  outputs: [
    { to: '1CBTGrChDDGsewF1eAV6FQyxRaSXRvUT7o', satoshis: 5000 },
    { data: [Buffer.from("Hello world!")] }

  .on('funded', payment => payment.pushTx())
  .on('success', txid => console.log('TX sent', txid))

Let's break it down step by step, and take a look at whats going on...

1. Create a payment invoice

The first block of code creates a Paypresto invoice using the given parameters. The private key is never exposed or sent remotely. The key is used to create a template UTXO which Paypresto gives to your users' wallet. The key is later used to sign and send your transaction.

const payment = Presto.create({
  // Provide WIF key, or bsv PrivKey or KeyPair instance
  key: 'Kx2p4o7FYJYjEwufdYJLXjPtu2vaSpQ8mB7mjMJnaHnPSrGQ1nQk',

  // Short human readable description of payment
  description: 'My test payment',

  // An array of outputs, can include simple p2pkh outputs,
  // custom scripts or embedded data
  outputs: [
    { to: '1CBTGrChDDGsewF1eAV6FQyxRaSXRvUT7o', satoshis: 5000 },
    { script: '76a91412ab8dc588ca9d5787dde7eb29569da63c3a238c88ac', satoshis: 5000 },
    { data: [Buffer.from("Hello world!")] }

You can add any number of inputs and outputs to the payment instance. Under the hood, Paypresto uses txforge so you can use the same API for defining inputs and outputs. This also means you can take advantage of Cast instances to construct custom locking and unlocking scripts.

2. Mount the widget

The payment widget can now be mounted within your app or web page. The default embed() function simply creates an iFrame in the given DOM element. More mount functions are in the pipeline to give you more flexibility with how you integrate the widget with yor app.

// The embed function can be passed DOM selector string or an HTML element

It's possible to customise the appearance of the widget.

// Additional stying options can also be given
  .mount(embed('#widget', { style: ['rounded', 'border-thick'] }))

/* Possible style options include:
   - border
   - border-thick
   - border-blue
   - border-blue-thick
   - border-green
   - border-green-thick
   - border-pink
   - border-pink-thick
   - rounded
   - rounded-bottom
   - shadow

3. Listen for callbacks

The user will interact with the widget and fund the payment with their own wallet. Events are emitted at certain points along the payment life-cycle. At the bare minimum you'll want to listen to the funded event to broadcast the transaction.

// Handlers can be attached to the following events
  .on('invoice', invoice => /* fired when invoice created */)
  .on('funded', payment => payment.pushTx())
  .on('success', txid => /* fired when tx successfully sent */)
  .on('error', err => /* fired when error is encountered */)

If you prefer to broadcast the transaction through your own channels, you can do this by customising the funded event handler.

  .on('funded', payment => {
    const rawtx = payment.signTx().getRawTx()

And that's it. As simple as 1-2-3: create the payment invoice; mount the widget, and listen for callbacks.

Frequently asked questions

How does it work?

The paypresto.js library allows you (and your apps) to construct complex transactions through its simple declarative API. The library then calculates the number of satoshis required to fund the transaction and creates a payment invoice on the Paypresto platform.

The invoice is then displayed to your users through an embeddable widget. Users can pay the invoice with their favourite wallet, which is sent peer-to-peer directly to the Paypresto platform. The UTXOs are immediately added to your transaction which can now be broadcast to the Bitcoin network.

What wallets are supported?*

The purpose of Paypresto is to let users interact with the Bitcoin world with their preferred wallet. We want to avoid creating walled gardens where users are limited to what they can access because they use the 'wrong' wallet.

We're committed to supporting any and every BSV wallet. That said, the service depends on peer-to-peer protocols so not every wallet will be compatible. If your wallet can send peer-to-peer and you don't see it in Paypresto, let me know.

Isn't this the same as Proxypay?

Proxypay was my first stab at solving this problem and depended on Planaria's Bitsocket to listen for funding UTXOs. Latency is the issue here and sometimes, especially during high tx volume periods, users are forced to wait too long for their funding UTXOs to be seen.

Paypresto is built on the same idea, rewritten from the ground up, and depending on no third party services. And because it is built on emerging peer-to-peer protocols it is fast! Your app will often be notifying users of a successful payment before their wallet has even confirmed the payment was sent.

Are there any fees?

A small fee is added to each transaction to pay for the service. During the beta there is one standard sliding scale, based on the USD value of the transaction (all outputs and the miner fee).

Range Fee
Upto $0.05 10% Minium fee is 140 satoshis
> $0.05 - $0.50 5%
> $0.50 - $5.00 1%
> $5.00 - upwards 0.5% Maximum fee is $2.50

To give you an example, a Twetch sized transaction costing $0.04 would have $0.004 added on top as fees. A large data payload costing $10 would have $0.07 added. Fees are capped at $2.50 and you'd need to be sending almost $500 to pay that.

What does "beta" mean?

Paypresto is currently a beta phase product. It's a functioning product and ready to be used, but being in beta has a few caveats: you may end up disvocering bugs that we havn't even discovered yet; the widget UI may undergo design changes as we tweak the user experience; as yet there are no terms of service or guarantees - you use the service as is and at your own risk.

Over the coming weeks the product will mature and settle, terms of service are being worked on, and plenty more features are in the pipe-line. In the meantime, please feel free to try Paypresto in your app, and let me know how you get on.