NEM NIS api transaction not working

So i sent some amount of my mosaic over NEM NIS Api(testnet), and I see the transaction in my wallet, but the amount is not increasing/decreasing from both of wallets. Indeed when sending from nanowallet everything is fine.
(upper transaction is sent with nem nis api, bottom with nanowallet)

/transaction/prepare-announce (post)
let transObj = {
            "timeStamp": createNEMTimeStamp(),
            "amount": 0,
            "fee": 1100000,
            "recipient": transInfo.recipient,
            "type": 257, 
            "deadline": createNEMTimeStamp() + 6000, 
            "message":
            {},
            "version": -1744830462,//1744830466, //ostaviti ovako za mainnet
            "signer": transInfo.publicKey,
            "mosaics":[
            {
                "mosaicId":{
                    "namespaceId": 'mudo',
                    "name": 'usd',
                },
                "quantity": parseFloat(transInfo.amount)
            }                  
        ]
        }
        let body = {
                transaction: transObj,
                privateKey:transInfo.privateKey
            }

Not a bug. Amount for mosaic transfers works as multiplier. You should set amount = 1000000 same as nanowallet.
Thank you.

and for quantity in mosaic obj?

For quantity in mosaic object amount of mosaic which you want send.

1 Like

So its a same thing, amount and quantity should have same value?

No.
amount = 1000000 (it mean that you will multiply by 1 because all is in mili xem. So 1000000 is 1000000 / 1000000 = 1)

and in in mosaic array quantity you want send for example if you want send 100 mudo:usd then:

amount: 1000000,

“mosaics”:[ {
“mosaicId”:{
“namespaceId”: ‘mudo’,
“name”: ‘usd’,
},
“quantity”: 100000000
}

You will send in this way 1 * 100 mudo:usd = 100 mudo:usd.

https://nemproject.github.io/#version-2-transfer-transactions

Ok, I get it, thank you. Can you tell me one more thing. How to encrypt payload in message?
{
“payload”: “this”,
“type”: 1
},

Can I ask what language you using?
If javascript maybe you should use nem-library or nem-sdk.

It is javascript on node.js
Its too late to use those libraries, I already wrote 400+ lines of code.

Those libraries have a lot more so you save time in future :slight_smile:
About message. You want send encrypted message or unencrypted? If unencrypted you must only encode payload. You should look at libraries I mentioned. You can copy code from them.

BTW Please make sure you using trusted or local node for prepare announce. Sending private key to untrusted node could cause lost of money and account. As far as I remember nanowallet don’t use prepare-announce. Instead of this it’s doing all cryptography (transaction signing) on client side and it sends signed transaction (/transaction/announce).