Skip to content

Instantly share code, notes, and snippets.

@mntmn
Created October 14, 2017 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mntmn/d8cbfdee8d0bd8dd021ef48115f2c032 to your computer and use it in GitHub Desktop.
Save mntmn/d8cbfdee8d0bd8dd021ef48115f2c032 to your computer and use it in GitHub Desktop.
const IOTA = require('./iota.lib.js/lib/iota.js')
const ccurlProvider = require('../iotaproxy/lib/ccurlprovider.js');
var iota = new IOTA({
'host': 'http://iota.bitfinex.com',
'port': 80
})
const seed='YOURSECRETSEED'
iota.api.getNodeInfo(function(err, info) {
console.log(info)
})
ccurlProvider.init()
var localAttachToTangle = function(trunkTransaction, branchTransaction, minWeightMagnitude, trytes, callback) {
console.log("Light Wallet: localAttachToTangle",trunkTransaction,branchTransaction,minWeightMagnitude,trytes)
ccurlProvider.attachToTangle(trunkTransaction, branchTransaction, minWeightMagnitude, trytes, function(error, success) {
console.log("Light Wallet: ccurl.ccurlHashing finished:")
if (error) {
console.log("error",error)
} else {
console.log("success",success)
}
return callback(error, success)
})
}
var localInterruptAttachingToTangle = function(callback) {
console.log("Light Wallet: localInterruptAttachingToTangle")
// actually this should probably not be commented out
//ccurl.ccurlInterrupt(connection.ccurlProvider)
if (callback) {
return callback()
}
}
iota.api.attachToTangle = localAttachToTangle
iota.api.interruptAttachingToTangle = localInterruptAttachingToTangle
var messageToSend = {
'url': 'https://blurb.example.org'
}
var messageStringified = JSON.stringify(messageToSend)
var messageTrytes = iota.utils.toTrytes(messageStringified)
var transfer = [{
'address': 'HTHJEOHEBGPTGIAJYOMCZGZNLSUTSJEHFAHLQLNQLOLXVIEFIKYKQZQAZCQUTPPWJCAD9DWJISXRUPPIZSEJWPVHBD',
'value': 1,
'message': messageTrytes
}]
// tip selection depth 4, magnitude 14
iota.api.sendTransfer(seed, 4, 14, transfer, function(e, bundle) {
if (e) throw e;
console.log("Successfully sent your transfer: ", bundle);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment