mintBlue

SDK

Install @mintblue/sdk, import it so it loads, authenticate a client, and know which version you are on.

Current SDK generation. This page documents the mintBlue SDK that ships today. Identity, mandate and signing semantics are specified by the open SDX Protocol. Read the specification

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

@mintblue/sdk is the JavaScript client. It creates transactions, fetches them back, decrypts what belongs to your account locally, and manages projects and event listeners. Everything on this page was checked against version 9.6.0.

If you work in another language, the same functions are reachable over HTTP through JSON-RPC.

Install

npm install @mintblue/sdk

The package declares "engines": { "node": ">=15" }, so Node 15 is the floor it states support for.

Import the client

The package publishes a CommonJS entry and an ESM entry, and in 9.6.0 they do not behave the same on a clean install.

The CommonJS entry is a bundle with its dependencies inlined, and it loads:

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

The ESM entry does not load after a plain npm install @mintblue/sdk. Its first line imports lodash/compact.js, and lodash is not among the package's declared dependencies, so Node has nothing to resolve and the import throws before your own code runs:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'lodash' imported from
  node_modules/@mintblue/sdk/dist/esm/lib/mintblue.js

Two ways round it, both available today. Import through the CommonJS entry, which is what require selects and what every sample on this site uses. Or, if your project needs the ESM entry, install lodash in that project alongside the SDK, which gives the import something to resolve.

The package also publishes two subpath entries: @mintblue/sdk/react for the React bindings, and @mintblue/sdk/umd for the browser bundle.

Authenticate

A client is created from an SDK access token. Create one in the console under Access Tokens; the Quickstart walks through it in step 5.

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

const client = await Mintblue.create({
  token: process.env.MINTBLUE_SDK_TOKEN,
});

Mintblue.create returns a client with your keys already unwrapped in memory, which is why the SDK can decrypt your own records without a secret being passed in. Saving a token in the console shows an SDK token and an API token at the same moment. The SDK token is the one this client takes. The API token authenticates calls to the API and cannot decrypt your keys, so treat the difference as a permission boundary rather than a naming detail.

Two other options on Mintblue.create are worth knowing about: url, which points the client at a different API host, and version, which pins the API version it talks to. Both default to the values the package ships with.

What the client exposes

AreaFunctions
TransactionscreateTransaction, getTransaction, listTransactions, queryTransactions, transactionsAfterTxid
ProjectscreateProject, getProject, updateProject, listProjects, destroyProject
Event listenerscreateEventListener, getEventListener, listEventListeners
MachinesregisterMachine, listMachines, and the static Mintblue.listMachineDescription
TokenscreateAccesstoken
Keyskeys, the key module on the client

A handful of further functions carry an experimental prefix in their own name, experimentalStreamProject among them. The prefix is the package's own signal that the shape may change, and it is worth reading as one.

createTransaction takes a project ID and an array of outputs, and the output is where the choices are: Output types covers each shape and what it publishes.

Signatures, option objects and return types for all of the above are generated from the source and published at mintblue.gitlab.io/sdk. That reference is the authority on the exact TypeScript shape of any call.

Versions

The npm package is versioned on its own. The samples on this site were checked against @mintblue/sdk 9.6.0.

The HTTP surface pins versions separately: a JSON-RPC request goes to /sdk/latest or to a specific published version, and the list of versions that endpoint serves is at api.mintblue.com/sdk/versions. The two numbering lines are not the same thing, so pin deliberately rather than by assuming they match.

Next

On this page