website logo
WebsiteTry DashboardContact Sales
โŒ˜K
๐Ÿ‘‹Welcome to mintBlue!
โ“Why Use mintBlue?
๐ŸงงmintBlue Products
โ›“๏ธEnterprise Bitcoin
๐Ÿš€Introduction
๐Ÿ‘‰mintBlue Quick Start Guide
๐Ÿ”—Setting up Zapier & mintBlue
๐ŸŽ‡mintBlue SDK
๐Ÿ‘‰SDK Quick Start Guide
๐Ÿ—๏ธSDK Encryption
๐Ÿ–ฅ๏ธSDK Server
๐Ÿ“ฉEnvelopes
๐Ÿ“SDK Scripts
๐Ÿ“–mintBlue API
โน๏ธBlockchain API
๐Ÿ–ฅ๏ธmintBlue Console
๐Ÿ‘‚Event Listeners
๐Ÿ†Examples of Building with mintBlue
๐Ÿ”‘password manager
๐Ÿ“ƒNotary Express App
Docs powered by
Archbee
mintBlue SDK

SDK Quick Start Guide

8min

Installation

Install the mintBlue SDK with npm using the command

JS
|
npm install @mintblue/sdk
๏ปฟ

Instantiate the SDK

In the example below, replace [YOUR_SDK_TOKEN] with the SDK token generated in mintBlue Quick Start Guide๏ปฟ

JS
|
const { Mintblue } = require('@mintblue/sdk');

const token = '[YOUR_SDK_TOKEN]';
const client = await Mintblue.create({token});
๏ปฟ

Generating a Transaction

The code snippet below shows how to generate a signed and encrypted data transaction.

JS
|

const outputs = [
    {
        type: 'data',
        value: 'Hello World!',
        sign: true,    // optional
        encrypt: true, // optional
  	}
];

const { txid, rawtx } = await client.createTransaction({project_id: '[PROJECT_ID]', outputs});

๏ปฟ

The outputs array contains objects according to the output definition. Valid output types are explained below.

Data

Data outputs are published in so called OP_RETURN scripts and use an envelope according to the Univrse spec. Data outputs are defined by setting the type property to 'data'. Valid data outputs require a value property, which can contain any object, including a simple string. Optional properties are sign and encrypt, both booleans, that result in the respective action when set to true. By default these properties are set to false.

Learn more about SDK Encryption๏ปฟ

Micropayment

Payment outputs result in default P2PKH outputs. Payment outputs are defined by setting the type property to 'payment'. Valid payment outputs require a to property containing either a paymail address or a Bitcoin SV address string. Payment outputs also require a satoshis property containing an integer defining the amount of satoshis that will be sent to the respective recipient. An example can be found here: Create a micropayment๏ปฟ

File

File outputs are defined by setting the type property to 'file'. A valid file output requires a property value containing an object with properties contentType (a string containing the content type), and content (a buffer containing the file's content). An example can be found here: Publish a file๏ปฟ Optionally, booleans sign and encrypt can be provided in the same way as a data transaction.

The maximum file size is 50MB per transaction.

๏ปฟ

Script

Script outputs can be used to create more complex smart contracts using the Bitcoin script language. Script output definitions need to contain a property encoding (which can be either 'base64', or 'hex') and a property value which needs to contain the script in a string encoded with the respective encoding.

๏ปฟ

Updated 21 Aug 2023
Did this page help you?
PREVIOUS
Create A Zapier Automation With mintBlue
NEXT
SDK Encryption
Docs powered by
Archbee
TABLE OF CONTENTS
Installation
Instantiate the SDK
Generating a Transaction
Data
Micropayment
File
Script
Docs powered by
Archbee