STORING MICRO TRANSACTIONS

IN THE IOTA TANGLE:

priceless.

What is the
tangle?

To attach a transaction

you must "confirm"

2 old transactions

they did

the same

meet the "directed acyclic graph" (D A G)

anatomy of a transaction 

name type tryte-length
hash String 81
signature fragment String 2187
address String 81
value Int
timestamp Int
currentIndex Int
lastIndex Int
bundle String 81
trunkTransaction String 81
branchTransaction String 81
nonce String 81

PoW

\}
}\}

older tx

\}
}\}

bundle info

how much?

tx's "name"

0 when value==0

where?

There are advantages.

  • no need to download the whole ledger
  • everyone can add new tx
  • you can create an offline ledger  ("subtangle") and add all of its tx later
  • the more people add tx the faster it gets
  • a tx can (but doesn't have to) contain a value
  • adding a tx is free

figure it out yourself:

https://simulation1.tangle.works/

Seeds, signatures & Addresses

  • Seed = origin for "random" numbers
    • keep it safe as a password 
  • ​"Winternitz" One-time signatures
    • index based deterministic signatures
  • Address: derivate hash of your seed
    • since based on the seed they're reproducible
    • if you would use one address more than once
      attackers could bruteforce guessing your seed.

Infrastructure

(optional)

IRI

  • IOTA Reference Implementation
  • Java
  • it's basically a "full" wallet ;)
  • needs "neighbor" nodes to work
    • the more neighbors the faster
  • must be visible from the outside world

nelson.cli

Nelson.GUI

Tools

Desktop wallet

CLI wallet

the tangle.org

Coding

stable APIs

  • Javascript
  • Python
  • Go

Hello IRI

const IOTA = require('iota.lib.js');
const iota = new IOTA({
    'provider': process.env.IRI_URL
});

iota.api.getNodeInfo( (error, success) => {
    if (error) {
        console.error(error);
    } else {
        console.dir(success);
    }
});

Attach a transaction

const IOTA = require('iota.lib.js');
const iota = new IOTA({
    'provider': process.env.IRI_URL
});

iota.api.getNewAddress('SOMESEEDTHATYOU9ENERATEDONYOUROWN', {}, (error, address) => {
    if (error) { return  console.error(error); }
    console.log('Got address: ' + address);
    const transfer = [{
        address: address,
        value: 0,
        message: iota.utils.toTrytes('hello world from coding berlin.'),
        tag: 'CODIN9BERLIN'
    }]
    const  depth = 8; // Depth for the tip selection
    const  minWeightMagnitude = 18; // If we're on the mainnet, minWeightMagnitude is 18
    // the sendTransfer API wrapper takes care of prepareTransfers, attachToTangle, broadcast and storeTransactions
    iota.api.sendTransfer( seed, depth, minWeightMagnitude, transfer, ( error, attached ) => {
        if (error) {
            return console.error(error);
        }
        console.log("Successfully attached your transaction to the Tangle with transaction", attached);
    });
});

IRI does the heavy lifting for us

List all transfers (aka bundles)

require('dotenv').config();
const IOTA = require('iota.lib.js');
const iota = new IOTA({
    'provider': process.env.IRI_URL
});
iota.api.getTransfers(process.env.CB_SEED, {}, (error, transfers) => {
    
    if (error) {
        console.error(error);
        return;
    }
    transfers.forEach(bundle => {
        bundle.forEach(t => {  
            let time = new Date(1000 * t.timestamp).toLocaleString();
            console.log(`${time} hash:${t.hash} value:${t.value} bundle:${t.bundle}} `);
        })
    })
});

Transfer list

And then

Masked Authenticated Messaging

  • encrypted
  • confirmed / authenticated
  • streamed

MAM

Attach a MAM message

require('dotenv').config();
var inquirer = require('inquirer');
var IOTA  = require('iota.lib.js');
var Mam = require('mam.client.js/lib/mam.node.js')

const iota = new IOTA({
    'provider': process.env.IRI_URL
});
const seed = process.env.CB_SEED;
// Initialise MAM State - PUBLIC
let mamState = Mam.init(iota, seed)

function promptMessage() {
    return inquirer.prompt([{type: 'input', name:'message', message: 'message' }]);
}

function publish(message) {
    let payload = iota.utils.toTrytes(message);
    let mamMessage = Mam.create(mamState, payload);   // Create MAM Payload - STRING OF TRYTES
        mamState = mamMessage.state // Save new mamState
        
        console.log('Root: ', mamMessage.root)
        //console.log('Address: ', mamMessage.address)
        return Mam.attach(mamMessage.payload, mamMessage.address)
}

(async () => {
  while(1) {
    let result = await promptMessage(); 
    let transactions = await publish(result.message);
    console.dir(transactions);
  }
})();
 

Decode MAM messages

require('dotenv').config();
var inquirer = require('inquirer');
var IOTA  = require('iota.lib.js');
var Mam = require('mam.client.js/lib/mam.node.js')

const iota = new IOTA({
    'provider': process.env.IRI_URL
});
Mam.init(iota)

const seed = process.env.CB_SEED;
const root = process.argv[2];

const logData = data => console.log(iota.utils.fromTrytes(data));

Mam.fetch(root, 'public', null, logData).then(resp => {
    console.dir(resp);
})

Sensor data marketplace

  • attach your sensor data to the tangle
  • charge for its usage
  • "data is the new oil" vs. "big data = big business"

It's not a bug

It's the future!

put tx on iota: priceless

By Stefan Adolf

put tx on iota: priceless

  • 558