Skip to main content

Quickstart

This guide walks through how to use the M10 SDK & CLI to create a new digital currency "My Bucks", currency code MYB. We will also create two bank issuance accounts, a customer account for each bank, issue funds and transfer between them. You will be assuming the role of the each participant throughout the process to better understand how the M10 Platform serves as an API for interaction between all network members.

You will:

  • create a new currency and onboard banks to new issuance accounts
  • create new cutomer accounts for each bank
  • send a transfer of funds between the two customer accounts at different banks
info

Before getting started, you'll need root issuance account issued to you by M10 and the associated private key. You'll also need to grab the latest SDK version from Github. The REPL provided throughout this guide already has these provided for your easy exploration.

Before we start

Following setup will be necessary for everything to work

  • CLI
  • TS
  • Rust
M10 REPLFOO

As the Central Bank

Everything starts with the central bank using the M10 platform to create and issue a new digital currency. In this section you will create the currency, the commercial bank accounts used to onboard new banks to the platform, and conduct a new issuance to them.


Create a new digital currency

You'll need your central-bank key pair in the PKCS8 format. To generate a new key-pair, enter the following command

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

created key pair file: "central-bank.pkcs8"
public key is:
"hOJIkyqJ7/dUStWzcgj+afT1dBvJKczPvl5q70MpMaY="

Create the root account for your new digital currency associated with your central bank public key:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Create the role and role-binding

It's necessary to grant the permissions to your central bank public key needed to create issuance accounts.

  • CLI
  • TS
  • Rust
M10 REPLFOO

Create issuance accounts for Bank One and Bank Two

The process for creating bank keys and issuance accounts is similar to the above. Using the provided public keys for Bank One and Bank Two, we create issuance accounts for their commercial use, and grant them permissions via new roles and role bindings.

Bank One

  • CLI
  • TS
  • Rust
M10 REPLFOO

Bank Two

  • CLI
  • TS
  • Rust
M10 REPLFOO

Issue funds to Bank One

To issue funds we need to create a transfer from root account to bank-one:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Transfer information

It's possible to get information about the transfer created above by using an id from the output:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

(
tx_id: 129630000,
context_id: [],
timestamp: "2022-08-25 10:39:55.210130",
steps: [
(
from: "0c000000000000000000000000000000",
to: "0c800000000000000000000000000002",
amount: 100000,
metadata: [
Memo((plaintext:"Funds")),
],
),
],
success: true,
state: Accepted,
)

Check the status of our new currency accounts thus far

Notice the change in the issued_balance before and after transfer in the root account:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

(
id: 0c000000000000000000000000000000,
balance: 0,
frozen: false,
code: "MYB",
decimals: 2,
balance_limit: 18446744073709551615,
issuance: Some((
balance: 100000,
issuance_accounts: 2,
holding_accounts: 0,
)),
)

As the Commercial Bank

Once a bank has been onboarded by the central bank onto the M10 platform, they can then use the API to effectively create and manage customer accounts. We will use the API act as two different commercial banks titled "Bank One" and "Bank Two". Each of these banks has a new customer we will create accounts for and deposit funds.


As Bank One, find my issuance account

Let's start exploring the M10 SDK by finding the issuance account you just created "As the Central Bank" for our use now as the Commercial Bank. We can list all of the accounts that we own — there should be only the one created for this tutorial, so we will use the first one returned as our issuance account. This code creates a new ListAccountsRequest filtering by our public_key as the owner. It then signs the request using our key-pair and sends it to the ledger.

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

[
(
id: "0c800000000000000000000000000002",
owner: "i+VZtoZhwLhfMZ2Etv23029ulURf1yz4Gb6RaqSGS9Y=",
name: "Bank One MYB",
public_name: "Bank One MYB Issuance Account",
profile_image_url: "",
),
]

As Bank One, create a customer account for Alice

Now we will create a new child account (for a user called Alice) under our issuance account. Alice needs her own public key to sign transactions with, so, first, we will generate that key and account-set:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Create role and role-binding

Since we just created bank-one it won't have any roles that we can use for customers. So we need to create a customer role and role-binding where we can use Alice as a subject:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Create ledger-account for Alice in bank-one

After everything is ready we will create a new ledger-account for Alice:

  • CLI
  • TS
  • Rust
M10 REPLFOO

As Bank One, issue funds to Alice's customer account

At the moment Alice's balance is zero, so we need to issue funds from her bank:

  • CLI
  • TS
  • Rust
M10 REPLFOO

As Bank Two, create a customer account for Bob

Just like we did with Alice a moment before, we will setup everything for Bob in bank-two:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Roles and role-binding need to be created for bank-two just like it was done for bank-one:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Create ledger-account for Bob in bank-two

  • CLI
  • TS
  • Rust
M10 REPLFOO

As Alice, send some of our new digital currency to Bob

Now that their customer accounts have been created and they've been granted access, Alice and Bob are likewise able to use the API to send and recieve their new digital currency. In this one action, the ledger tree hierarchy of accounts will allow a double-entry accounting like atomic transaction that all participants in the activity will be able to observe and respond to.


Check current balance

After we issued 1000 MYB from bank-one into Alice's account we should the same amount as a balance:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

(
id: "0c800000000000000000000000000003",
balance: 1000,
frozen: false,
code: "MYB",
decimals: 2,
balance_limit: 18446744073709551615,
issuance: None,
)

Transfer funds to Bob

Now that we have 2 accounts for customers, and at least one of them has funds, we can make a transfer:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Look up recent transfers to confirm delivery

Below you can see how we can get a list of transfers. At the moment they are filtered only by account, but there are a few other options which you can use to enchance or filter the output:

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

In the output you'll see all the transfers that we just made:

[
(
tx_id: 133930000,
context_id: [],
timestamp: "2022-08-25 10:42:42.786861",
steps: [
(
from: "0c800000000000000000000000000003",
to: "0c800001000000000000000000000003",
amount: 100,
metadata: [Memo((plaintext:"groceries"))],
),
],
success: true,
state: Accepted,
),
(
tx_id: 132160000,
context_id: [],
timestamp: "2022-08-25 10:41:53.310156",
steps: [
(
from: "0c800000000000000000000000000002",
to: "0c800000000000000000000000000003",
amount: 1000,
metadata: [Memo((plaintext:"Funds"))],
),
],
success: true,
state: Accepted,
),
]

Check balance again to confirm debit of funds

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

(
id: "0c800000000000000000000000000003",
balance: 900,
frozen: false,
code: "MYB",
decimals: 2,
balance_limit: 18446744073709551615,
issuance: None,
)

As Bob, confirm receipt of funds

Check balance to confirm credit of funds

  • CLI
  • TS
  • Rust
M10 REPLFOO

Output

(
id: "0c800001000000000000000000000003",
balance: 100,
frozen: false,
code: "MYB",
decimals: 2,
balance_limit: 18446744073709551615,
issuance: None,
)

As you can see Bob now holds the funds sent by Alice. You've now completed a basic exploration of the features of the M10 platform. For further exploration, attempt to request the transaction information and the account information using the different keys you created throughout the process. Which personas can see with activities? Understanding how RBAC & the ledger hierarchy influences access to model the compliance requirements found in financial services is a key area of mastery to get the most out of M10.