Quickstart
From a new account to an encrypted, signed record submitted from your own code, and read back again.
A first record takes seven steps: two in the console, five in your editor.
Before you start
You need Node 15 or newer, which is what @mintblue/sdk declares support for,
and a directory to work in. Everything else is created as you go.
The console does the account and project work in steps 1 and 2, and does nothing else in this Quickstart. If you would rather see a transaction take shape in a browser before you write code, the Composer does that, and the console page covers it along with projects, access tokens and event listeners.
Step 1: Create an account
Sign up at console.mintblue.com, then log in. Your keys are generated on your device during sign-up, so the password you choose here is part of your key material rather than a login detail. What that means in practice is set out in Non-custodial keys.
Step 2: Create a project
A project is the container your records are submitted into and listed from. In
the console, open Projects and create one.
Copy its project ID from the project's overview page. The SDK needs it on every call that writes a record, and the rest of this page assumes you have it.
Step 3: Install the SDK
npm install @mintblue/sdkThe package is @mintblue/sdk on npm, and the version these samples were
checked against is 9.6.0.
Step 4: Write the submit script
Save this as submit.js. It reads its credentials from the environment, so
nothing secret ends up in the file. If your project sets "type": "module",
name the file submit.cjs instead and adjust the commands below.
const { Mintblue } = require('@mintblue/sdk');
(async () => {
const client = await Mintblue.create({
token: process.env.MINTBLUE_SDK_TOKEN,
});
const { txid } = await client.createTransaction({
project_id: process.env.MINTBLUE_PROJECT_ID,
outputs: [
{
type: 'data',
value: 'invoice INV-0001 approved',
sign: true,
encrypt: true,
},
],
});
console.log(txid);
})();Three things in that call are worth naming. type: 'data' is the general
purpose output for a data packet. sign: true attaches a digital signature made
with your own key, so a recipient can check who wrote the record without asking
mintBlue. encrypt: true encrypts the value before it leaves your machine.
Leave encrypt out and the value is published in the clear.
Step 5: Create an access token
The SDK authenticates with an access token, which you create once in the console
under Access Tokens in the account menu. Saving a new token shows you two
strings at the same moment, and that is the only moment either is shown.
Which token to use
The SDK token carries the secret that lets the SDK decrypt your keys locally, which is why it, and not the API token, is the one this Quickstart uses.
The API token authenticates calls to the mintBlue API and cannot decrypt your keys. Use it where a service only needs to talk to the API, a Zapier automation for example, and treat the difference as a permission boundary rather than a naming detail.
Store both somewhere your team already keeps secrets. The console does not show them again, so a lost token is replaced rather than recovered.
Step 6: Submit the record
Put the token and the project ID in your environment and run the script.
export MINTBLUE_SDK_TOKEN="your SDK token"
export MINTBLUE_PROJECT_ID="your project id"
node submit.jsThe script prints one transaction ID. That ID is how you fetch the record back, and it is what appears in the console under the project's transactions.
Step 7: Read the record back
Save this as read.js and pass the transaction ID as an argument.
const { Mintblue } = require('@mintblue/sdk');
(async () => {
const client = await Mintblue.create({
token: process.env.MINTBLUE_SDK_TOKEN,
});
const transaction = await client.getTransaction({
txid: process.argv[2],
parse: true,
});
console.log(transaction.outputs);
})();node read.js THE_TRANSACTION_ID_FROM_STEP_6parse: true asks the SDK to parse the outputs of the fetched transaction and
return them in the outputs field. Because the record was encrypted with your
own keys, decryption runs for the account that submitted it without a secret
being passed in, and the value you sent comes back readable.
Where to go next
The developer path
The order to read the rest of these docs in.
Non-custodial keys
Which key does what, and what mintBlue holds in each deployment model.
Event listeners
React to a record the moment it lands, instead of polling for it.
Reference
The exact SDK surface, the output types and the JSON-RPC endpoint.