NCC API Not Able to Send XEM

I’m trying to work with the NCC API to send an XEM transaction using node.js. I’ve followed the documentation found here but when i try to use this call with my updated data, I get:

{ timeStamp: 42053219,
  error: 'Bad Request',
  message: 'expected value for property version, but none was found',
  status: 400 }

So naturally, I assume the documentation is wrong and I simply need to add a ‘version’ field to my data that im posting to this endpoint. I hard code ‘1744830465’ (which i read is for the main network) into a ‘version’ property of my data and post. I get:

{ timeStamp: 42053158,
  error: 'Bad Request',
  message: 'version cannot overlap with reserved network byte',
  status: 400 }

Can someone please help me figure this out? I feel partly like the documentation is wrong, but also I feel like I’m missing something.

Sterling

Hi, I did the doc a while ago so yeah it is probably out of date a bit ^^. I don’t remember using a version… I completely forgot since I moved to full javascript. You should too because NCC will probably be dropped.

Look at the lightwallet code, you can do everything in js: https://github.com/NemProject/nem-lightwallet/tree/master/lightwallet

Interesting parts:
CryptoHelpers: https://github.com/NemProject/nem-lightwallet/blob/master/lightwallet/utils/CryptoHelpers.js
Keypair: https://github.com/NemProject/nem-lightwallet/blob/master/lightwallet/utils/KeyPair.js#L67
Build transactions and serialisation : https://github.com/NemProject/nem-lightwallet/blob/master/lightwallet/services/Transactions.js#L532
Also Gimre’s tutorial about serialization: Understanding transaction serialization (low-level, here we come)

If you still want to try with NCC, here is what I got from a transaction using Nano Wallet

{
“type”: 257,
“version”: 1744830465,
“signer”: “0257b05f601ff829fdff84956fb5e3c6547…”,
“timeStamp”: 42078300,
“deadline”: 42081900,
“recipient”: “NBCI2A67UQZAKCR6NS4JWAEICEIGEIM72G3…”,
“amount”: 0,
“fee”: 10000000,
“message”: {
“type”: 1,
“payload”: “”
},
“mosaics”: null
}

Not sure it can help as it’s different from NCC API.
Try to just add:

“mosaics”: null

In your TransferSendRequest object with and without version, at the time I wrote the doc there was no mosaics and it might need to be specified depending of what NCC is doing of the data.

1 Like

Thanks for your response @Quantum_Mechanics

I got it to work a little bit differently. I’ll need to include the private key into another field. So with that said, how do i extract the private key of an account? I know there’s a way because I was able to do it in the NCC browser UI on my local client. Now how can I do that in my code?

Oh, and one other thing. I’m using NIS to make the transaction, but my message is being encoded or encrypted or something. I put my message in the message.payload field and give message.type =1 but on the NCC browser UI, my message does not show up as I put it in payload.

For the private key using NCC you need to post a WalletNamePasswordBag object to ‘/wallet/account/reveal’

WalletNamePasswordBag object:

{
“wallet”: “PrivateWallet”,
“password”: “Very Secret Password To The Wallet”,
“account” : “TCN33UYH7OREBBFPA4D7GAE6TALNAZJOF6ZPDVA2” (# optional but might be required)
}

Sources:

For the message try doing:

“message”: “Your message”,
“encrypt”: 0

instead of

“message”: {
“payload”: “payload”, (payload is not plaintext but HEX data)
“type”: 1
}

Source:

Ok Great! Thank you for the first part. I’ll be needing that. The second part (the message) however is still not working. I made the POST with data like you said and I get:

{ timeStamp: 42480055,
  error: 'Internal Server Error',
  message: 'java.lang.String cannot be cast to net.minidev.json.JSONObject',
  status: 500 }

Oh but I just tried with Hex in the payload and fixed it xD TY!