George Kartsonas
Published © Apache-2.0

Instant Pay With IOTA

We are quickly reaching the technological point were transactions for services like transportation will be paid using crypto currencies.

BeginnerProtip1 hour32
Instant Pay With IOTA

Story

Read more

Code

IOTA Transaction Code

JavaScript
// IOTA library
const IOTA = require("iota.lib.js") 

// IOTA node
const iota = new IOTA({provider: "https://nodes.testnet.iota.org:443"})

// IOTA Proof of Work location
const remoteCurl = require('@iota/curl-remote')
remoteCurl(iota, `https://powbox.testnet.iota.org`, 500)

// Confirm node is working
iota.api.getNodeInfo((error, success) => {
  if (error) {
    console.log(error)
  } else {
    console.log(success)
  }
})

const trytes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9'
const message = iota.utils.toTrytes('YourMessage')
const transfers = [
  {
    value: 0,
    address: trytes,
    message: message
  }
]

iota.api.sendTransfer(trytes, 3, 9, transfers, (error, success) => {
  if (error) {
    console.log(error)
  } else {
    console.log(success)
  }
})

Credits

George Kartsonas
19 projects • 46 followers
Contact

Comments

Please log in or sign up to comment.