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?
https://simulation1.tangle.works/
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);
}
});
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);
});
});
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}} `);
})
})
});
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);
}
})();
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);
})
It's the future!