TransWikia.com

toTrytes() does not work

Iota Asked by Mo G. on August 21, 2021

I’m always getting this error without understanding why.

TypeError: Cannot read property 'toTrytes' of undefined

Code:

// Require the use of IOTA library
const Iota = require('@iota/core')

// Create a new instance of the IOTA class object.
// Use 'provider' variable to specify which Full Node to talk to
const iota = Iota.composeAPI({
  provider: 'https://nodes.devnet.iota.org:443'
})

// Call the 'getNodeInfo call to check that the node is working
iota.getNodeInfo()
    .then(info => console.log(info))
    .catch(err => {})

//Actual Transaction
const address =
  'HELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDD'
const seed =
  'PUEOTSEITFEVEWCWBTSIZM9NKRGJEIMXTULBACGFRQK9IMGICLBKW9TTEVSDQMGWKBXPVCBMMCXWMNPDX'
const message = iota.utils.toTrytes('Hello World!')

const transfers = [
  {
    value: 0,
    address: address,
    message: message
  }
]

iota
  .prepareTransfers(seed, transfers)
  .then(trytes => iota.sendTrytes(trytes, 3, 9))
  .then(bundle => {
    console.log(bundle)
  })
  .catch(err => {
    // catch any errors
  })

2 Answers

UPDATE 2021

Please be aware that IOTA has changed at architectural level.

Read about it in the official documentation: https://docs.iota.org/

Answered by Antonio Nardella on August 21, 2021

Maybe this will work:

const Converter = require('@iota/converter') const message = Converter.asciiToTrytes('MAYBE LIKE THAT')

Answered by K-Doe on August 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP