Money Button Documentation

Money Button Documentation

  • Money Button
  • API
  • Examples
  • Paymail
  • bsv

›Examples

Money Button

  • Money Button Overview
  • HTML
  • Javascript
  • React
  • Crypto Operations
  • Invisible Money Button
  • Paymail Signatures
  • Paymail Encryption
  • Simple Fabriik Protocol for Tokens

API

  • API Overview
  • Apps
  • Webhooks
  • Tokens
  • Currencies
  • Javascript Client
  • Authentication

    • Authentication Overview
    • OAuth
    • OAuth With JS Client

    API v1

    • Get User Identity
    • Get User Profile
    • Get User Balance
    • Get Payments
    • Get Payment By ID

    API v2

    • Get User Balances
    • Get Payments
    • Get Payment By ID
    • Get Assets
    • Create Asset
    • Modify Asset

Examples

  • Examples Overview
  • OP_RETURN Scripts
  • Assets

Paymail

  • Paymail Overview
  • Paymail Video Series
  • Paymail Introduction
  • BRFC Specifications
  • Specification Documents
  • BRFC ID Assignment
  • Service Discovery
  • Host Discovery
  • Capability Discovery
  • Public Key Infrastructure
  • Payment Addressing
  • Payment Addressing (Basic Address Resolution)
  • Payment Addressing (Payer Validation)
  • Payment Addressing (Payee Approvals)
  • Payment Addressing (PayTo Protocol Prefix)
  • Verify Public Key Owner
  • P2P Transactions
  • P2P Payment Destination
  • Recommendations

Bitcoin SV Library (bsv)

  • Bitcoin SV Library (bsv)
  • Big Numbers
  • Points (Elliptic Curves)
  • Hash Functions
  • Base 58
  • Private Keys
  • Public Keys
  • Addresses
  • ECDSA
  • Bitcoin Signed Messages
  • Signatures
  • HD Private Keys (BIP32)
  • HD Public Keys (BIP32)
  • Mnemonics (BIP39)
  • Script

Assets

Money Button allows developers to create assets using the BSV blockchain by implementing different token protocols. In our terminology, we call "assets" to what is more commonly referred to as "tokens".

If you haven't already, take a look into our tokens section.

Let's see a full example of an app that allows its users to create assets and transfer tokens that will be shown in their Money Button account.

Request permissions

The first step will be to use our OAuth integration to sign-in your users, requesting the following permissions:

ScopeDescription
users.asset:writeAllows to define a new asset
users.asset:readAllows to read all defined assets

In addition to this asset-related scope, you'll probably want to add other permissions like users.balance:read to access the user's balances (BSV and assets/tokens).

Follow the steps explained in OAuth with JS Client to complete the sign-in process.

Create an asset

To create an asset the user will need to complete two steps:

  1. Define the asset's properties
  2. Mint the tokens

Defining an asset

This first step just gives Money Button information about the asset that you want to create, without making any transaction or writing any information in the blockchain.

You can use our JS client to do this:

const client = new MoneyButtonClient('<OAUTH CLIENT IDENTIFIER>')

client
  .createAsset(
    'SFP@0.1', // Protocol to use
    'My First Asset', // Asset name
    1000 // Initial supply
  ).then(result => {
    console.log(result.paymailAlias)
  })

The JS client is using our Create Asset API endpoint.

After that call your user's asset will be defined and ready to be minted. Check our supported protocols to see which protocols you may use.

After defining an asset you will receive a random "paymail alias" that will be used to identify this asset. This is what we will use to mint the tokens in the next step, and what will be used to perform transfers.

Minting tokens

To actually record the tokens in BSV blockchain, we need to perform a "minting" transaction. For this you can use our JS client to render a button that will be used to create and send that transaction.

const client = new MoneyButtonClient('<OAUTH CLIENT IDENTIFIER>')

client
  .createAsset(
    'SFP@0.1', // Protocol to use
    'My First Asset', // Asset name
    1000 // Initial supply
  ).then(result => {
    // Render a button to mint the tokens
    moneyButton.render(document.getElementById('mb-button'), {
      outputs: [
        {
          asset: result.paymailAlias + "@moneybutton.com",
          amount: result.initialSupply,
        }
      ]
    })
  })

In this example, once the asset is defined, the button will be rendered so the user can swipe and send the minting transaction. As you can see there's no address field since the user will receive all the minted tokens.

Transfer an asset

When a user has a particular asset you can use the asset's paymail to render buttons that can transfer them:

moneyButton.render(document.getElementById('mb-button'), {
  outputs: [
    {
      to: "rob@moneybutton.com",
      asset: "73ade9edf94b.asset@moneybutton.com",
      amount: 150,
    }
  ]
})

With these two examples you can create an app that creates tokens and allows your users to transfer them by simply swiping, just as they do to transfer BSV.

← OP_RETURN ScriptsPaymail Overview →
  • Request permissions
  • Create an asset
    • Defining an asset
    • Minting tokens
  • Transfer an asset
Money Button Documentation
Docs
Money ButtonAPIDesignbsv
Community
redditYoutubeTelegramTwitter
More
BlogInstagramGitHubStar
See an error in our documentation? Issue a pull request to fix it.
Copyright © 2021 Yours Inc.