mintBlue

Payment Output

The payment output shape, a worked example, how it is billed, and how it reads back.

Current SDK generation. This page documents the payment output the mintBlue SDK accepts today. Addressing and discovery are specified by the open SDX Protocol. Read the specification

Generations sets out which document applies to the code you installed.

A payment output transfers value to an address as part of a transaction. It is one of the shapes listed under Output types, and it is documented here because it has properties and billing behaviour the others do not.

The shape

interface PaymentOutput {
  type: 'payment';
  // Recipient's paymail address or address string
  to: string;
  satoshis: number;
}

to takes either a paymail address or a plain address string. satoshis is an integer amount and the field takes no decimal part. The generated declaration is published at PaymentOutput.

Creating one

const outputs = [
  {
      type: 'payment',
      // to: 'name@paymail.com' // paymail address
      to: '12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX',
      satoshis: 1000,
  }
];

Pass the array to createTransaction with your project ID:

const { txid, rawtx } = await client.createTransaction({
  project_id: "<YOUR-PROJECT-ID>",
  outputs,
});

The call returns the transaction ID and the raw transaction data.

Billing

Payment outputs are billed separately from the rest of a transaction. The price is taken at the moment the transaction is created and carries a margin that depends on your plan, so a batch sized on last month's figure is a batch sized on the wrong figure. Your plan is the place to check the current margin.

Reading it back

Fetch the transaction with parse: true and the outputs come back in the shape they went in. The same view is in the console under the project's transactions, at console.mintblue.com/projects.

[
  {
    "type": "payment",
    "to": "12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX",
    "satoshis": 1000
  },
  {
    "type": "payment",
    "to": "1Juc9Tjmb6wc6yCaWFuB9QdEEQ621992ks",
    "satoshis": 23848
  }
]

The whole thing

const { Mintblue } = require("@mintblue/sdk");

async function main() {
  const token = "<YOUR-SDK-TOKEN>";
  const client = await Mintblue.create({ token });

  const outputs = [
    {
      type: 'payment',
      // to: 'name@paymail.com',
      to: '12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX',
      satoshis: 1000,
    }
  ];

  const { txid, rawtx } = await client.createTransaction({
    project_id: "<YOUR-PROJECT-ID>",
    outputs,
  });
  console.log(txid);
}

main();

require rather than import is deliberate: see importing the client.

On this page