Created
October 30, 2018 17:28
-
-
Save pasupulaphani/e22048046bd893f19678ec9595595b6d to your computer and use it in GitHub Desktop.
new IOTA NodeJs API (1.0.0-beta.5) transaction example
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
const { composeAPI } = require('@iota/core') //1.0.0-beta.5 | |
const { asciiToTrytes } = require('@iota/converter') //1.0.0-beta.5 | |
const iota = composeAPI({ | |
provider: 'https://nodes.devnet.iota.org:443' | |
}) | |
async function makeTx(seed, address) { | |
const transfers = [{ | |
address: address, | |
value: 1, | |
tag: asciiToTrytes('node-tx'), | |
message: asciiToTrytes('Hello World!') | |
}] | |
const minWeightMagnitude = 9 //devnet | |
const depth = 3 | |
// bundle prep for all transfers | |
const trytes = await iota.prepareTransfers(seed, transfers) | |
const bundle = await iota.sendTrytes(trytes, depth, minWeightMagnitude) | |
console.log(`Published transaction with tail hash: ${bundle[0].hash}`) | |
console.log(`Explorer link: https://devnet.thetangle.org/transaction/${bundle[0].hash}`) | |
} | |
const senderSeed = '<seed>' | |
const addressTo = '<address>' | |
makeTx(senderSeed, addressTo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment