Created
May 11, 2018 06:20
-
-
Save lewisdaly/4e23608bb93f3517f7dff0160aa19461 to your computer and use it in GitHub Desktop.
A simple IOTA MAM Subscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare var require: any | |
declare var process: { | |
env: { | |
ROOT: string | |
} | |
} | |
var Mam = require('../lib/mam.node.js') | |
var IOTA = require('iota.lib.js') | |
var iota = new IOTA({ provider: `https://testnet140.tangle.works` }) | |
// Init State | |
let root = process.env.ROOT; | |
console.log('Listening to root:', root); | |
// Initialise MAM State | |
var mamState = Mam.init(iota) | |
const execute = async () => { | |
const resp = await Mam.fetch(root, 'public'); | |
console.log(resp); | |
if (resp.nextRoot) { | |
root = resp.nextRoot; | |
execute(); | |
} | |
} | |
execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment