How to use iota - 10 common examples

To help you get started, we’ve selected a few iota examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github peterwilli / IOTA-Snapshot-Recovery / main.js View on Github external
var IOTA = require('iota.lib.js');
var fs = require("fs")
var iota = new IOTA({
  'provider': 'http://node01.iotameetup.nl:14265'
});
var seed = process.argv[2] + "" // in case the seed is all 9's (GOSH I HOPE NOT)
var depositSeed = process.argv[3] + ""
var status = 'checking'
var snapshot = fs.readFileSync('snapshot_validation_20171023.txt').toString().split("\n");

if (seed.length !== 81) {
  console.error("Seed is not 81 characters!")
  return
}

if (depositSeed.length !== 81) {
  console.error("Deposit Seed is not 81 characters!")
  return
}
github l3wi / mam.client.js / example / publishPrivate.js View on Github external
var Mam = require('../lib/mam.node.js')
var IOTA = require('iota.lib.js')
var iota = new IOTA({ provider: `https://testnet140.tangle.works` })

// Initialise MAM State
var mamState = Mam.init(iota)

// Set channel mode
mamState = Mam.changeMode(mamState, 'private')

// Publish to tangle
const publish = async packet => {
    // Create MAM Payload - STRING OF TRYTES
    var message = Mam.create(mamState, packet)
    // Save new mamState
    mamState = message.state
    console.log('Root: ', message.root)
    console.log('Address: ', message.address)
    // Attach the payload.
github l3wi / mam.client.js / example / publishPublic.js View on Github external
var Mam = require('../lib/mam.node.js')
var IOTA = require('iota.lib.js')
var iota = new IOTA({ provider: `https://testnet140.tangle.works` })

// Initialise MAM State - PUBLIC
var mamState = Mam.init(iota)

// Publish to tangle
const publish = async packet => {
    // Create MAM Payload - STRING OF TRYTES
    var message = Mam.create(mamState, packet)
    // Save new mamState
    mamState = message.state
    // Attach the payload.
    console.log('Root: ', message.root)
    console.log('Address: ', message.address)
    await Mam.attach(message.payload, message.address)

    // Fetch Stream Async to Test
github l3wi / mam.client.js / example / index.js View on Github external
var Mam = require('../lib/mam.node.js')
var IOTA = require('iota.lib.js')
var iota = new IOTA({ provider: `http://p103.iotaledger.net:14700/` })

const example = async () => {
  // Init State
  let state = Mam.init(iota)
  // Create Message one
  console.log('Creating MAM payload')
  var message1 = Mam.create(state, `POTATO`)
  state = message1.state
  console.log('Root: ', message1.root)
  // Attach that message
  await Mam.attach(message1.payload, message1.root)

  // Create Message Two
  console.log('Creating MAM payload')
  var message2 = Mam.create(state, `MASHEPOTATOE`)
  state = message2.state
github akashgoswami / ipm / index.js View on Github external
});
    }
    catch(e){
        s.emit('result', e.message);
    }
  });
  
  s.on('updateTag', function (data) {
       gTags[data.address] = data.tag;
       saveConfig();
  });

});

// Create IOTA instance directly with provider
var iota = new IOTA({
    'provider': (argv.iri || 'http://localhost:14800')
});

function updateNodeInfo(){
    sockets.forEach(function (s){
        s.emit('nodeInfo', gNodeInfo);
    });
}

function updatePeerInfo(peer){
    gPeerInfo.forEach(function(peer){
           peer.tag = gTags[peer.address] || 'Unknown Peer';
           sockets.forEach(function (s){
                s.emit('peerInfo', peer);
            });
    });
github l3wi / mam.client.js / example / publishRestricted.js View on Github external
var Mam = require('../lib/mam.node.js')
var IOTA = require('iota.lib.js')
var iota = new IOTA({ provider: `https://testnet140.tangle.works` })

// Initialise MAM State
var mamState = Mam.init(iota)

// Set channel mode
mamState = Mam.changeMode(
    mamState,
    'restricted',
    'IREALLYENJOYPOTATORELATEDPRODUCTS'
)

// Publish to tangle
const publish = async packet => {
    // Create MAM Payload - STRING OF TRYTES
    var message = Mam.create(mamState, packet)
    // Save new mamState
github l3wi / mam.client.js / example / fetchSync.js View on Github external
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 = ''

// Initialise MAM State
var mamState = Mam.init(iota)

// Publish to tangle
const publish = async packet => {
    var message = Mam.create(mamState, packet)
    mamState = message.state
    await Mam.attach(message.payload, message.address)
    return message.root
}

const execute = async () => {
github pRizz / iota-transaction-stream / routes / iotaNodeListener.js View on Github external
/*!
 * IOTA Transaction Stream
 * Copyright(c) 2017 Peter Ryszkiewicz
 * MIT Licensed
 */

const zmq = require('zeromq')
const iotaLib = require('iota.lib.js')
const iota = new iotaLib({})


let txCount = 0
let tpsInterval = 30 // seconds

setInterval(() => {
    console.log(`${new Date().toISOString()}: TPS: ${txCount / tpsInterval}`)
    txCount = 0
}, tpsInterval * 1000)

let transactionCallback = () => {}

function setTransactionCallback(callback) {
    transactionCallback = callback
}
github l3wi / mam.client.js / example / fetchAsync.js View on Github external
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 = ''

// Initialise MAM State
var mamState = Mam.init(iota)

// Publish to tangle
const publish = async packet => {
    var trytes = iota.utils.toTrytes(JSON.stringify(packet))
    var message = Mam.create(mamState, trytes)
    mamState = message.state
    await Mam.attach(message.payload, message.address)
    return message.root
}
github gagathos / iota-gpu-pow / remotePOW.js View on Github external
"use strict"

const IOTA = require('iota.lib.js')
const ccurl = require('ccurl.interface.js')
const express = require('express')
const body = require('body-parser')
const program = require('commander')

program
  .version('1.0.0')
  .option('-m, --max-mwm [mwm]', 'Max Minimum Weight Magnitude', 15)
  .option('-p, --port [port]', 'Port to host the server on', 80)
  .option('-c, --ccurl [ccurlLocation]', 'Directory of libccurl.so', '.')
  .parse(process.argv)

const iota = new IOTA()

const powServer = express()
powServer.use(body.json())
powServer.use(body.urlencoded({extended:true}))

var totalrequests = 0
var averagetime = 0

const postHandler = (req, res) => {
	// Set custom headers for CORS
	res.header("Access-Control-Allow-Origin", req.headers.origin) // restrict it to the required domain
    res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS")
    res.header("Access-Control-Allow-Headers", "Content-type,Accept,X-Custom-Header,X-IOTA-API-Version")
    
    switch(req.body.command){
    case 'getNodeInfo':

iota

A super-simple integer iteration function

MIT
Latest version published 12 years ago

Package Health Score

42 / 100
Full package analysis

Popular iota functions

Similar packages