NEM Random Game Discussion


Welcome to the thread about the NEM Random Game. Here you can discuss everything about the code and potential problems that you might stumble upon.


The video was freezing so I rebooted my computer, now when I launch NanoWallet all of my history is gone, for both accounts and I show zero balance. I did save the original key but don[t see how to import, the key, just the wallet. I hope I did not burn all my filipcoin :frowning: I can still send in code so I guess I can work but without verifying in the wallet


Everything is fine now, I had to choose a different node to connect to. I guess the red dot next to the “Node” tab was the indication that it was offline, seems like that could be improved some.


Great to hear you solved it. If you need to import a private key into nanowallet in the future, click the sign up button at the start of the nanowallet. Then select private key wallet instead of simple wallet.


Hey there, I have a couple questions…

I happened to use my own wallet information at the beginning my password and private key though used “filip” as my namespace and “score” as my mosaic name as in the following (note I created crazycanadia : score within my own account):

Where I used my own wallet which does not have a “filip” namespace but I have mine, “crazycanadia” I completed a transaction which looked like the following:

I’m wondering what really got sent from my primary account to itself because I don’t have any filip namespace?
Is this just a glitch when sending and receiving from the same account?

More than this, if I use my proper namespace and mosaic name the transfers seem to go through without a problem, however, the accounts which were awarded these mosaics are not able to transfer them. I have tried two different ways to transfer these “transferable: true” mosaics, one direct account to account, and the other through the game we made:

The above picture shows that this account should have the 50,000 sent at the bottom from my originating account plus the game rewards which come from the same originating account. The picture below however shows what the account actually possesses and is able to transfer out:

So, despite all appearance of transferring in the game as a reward, these don’t seem to actually be available to the winning account. What is happening? Why can I send these to others?


Hey @CrazyCanadia,

I had the same Problem. The mosaics send from the game showed up in the transaction history but not in the Explorer and I couldn’t send them either. While creating the transferTransaction the amount is set to 0. If you set it to 0 you can send basically every mosaic that exists on the NEM blockchain thats why you were able to send filip:score but you don’t really send them. I don’t really understand why that behaviour is wanted and why those transaction are valid but maybe there is a reason behind it. I also noticed if you set the amount to 1 you don’t send 1 XEM so amount means something else maybe amount of mosaic attachments I didn’t test that yet. To summarize, all you have to do is transferTransaction.amount = 1 and it should work properly.

Edit: I did some more testing and found out that if I set transferTransaction.amount to 10 for example, I send 10x the amount of mosaics. The transaction itself shows the right amount but if I check my balance in the explorer I can see that I acutally got way more mosaics in my case 10x the amount.


Thank you @nflaig for the reply, I’m going kinda crazy… (pun not intended)

You’re right, it seems the transferTransaction.amount is some kind of multiplier. I tested the same cases and found the same results. The transaction details say the right quantity, though what is transferred is that quantity*amount. Very strange.


Good digging guys. I was not aware of this. Seems like weird behaviour indeed of the NEM code…


Hi, I have a question please. How is it possible that I am able to commit those transactions from an account with no xem? I have commited 2 high scores and the transaction says 0.5 XEM fee on them both but I have never had any XEM in this account. I was expecting there to be an error but there was not and I can see the transactions in nano wallet. Although testnet explorer shows the transactions with fee of 0.5, it says the total mosaic quantity to be 0.0000 whereas nano shows 0.913506 so perhaps the transaction did not happen and this is some kind of bug in nano wallet which is showing invalid transactions??



I’m not sure about this actually. Haven’t seen or tried that before. Maybe someone else have any input here in the forum? Did you receive the mosiacs in the other account?


It was the receiving account which had no xem but did receive the mosaics. My understanding is that the receiving account must pay the 0.5XEM fee to receive the mosaics, is this correct? I definitely received the mosaics and definitely did not have any XEM in the account.


No the fee is payed by the sender. So as long as the sender account had XEM it looks normal.


the github code for NEM random game pt 2 is missing:

var scores = {};


Thank you so much. I have updated it now.


Hi Filip,

I understand that in the game and bank videos the purpose is to show in a simple manner how from a web interface you can communicate with the NEM blockchain. So I was wondering whether putting part of the code in a nodejs server and the frontend would be just the same as any simple page that sends ajax requests to the backend and is the backend the one communicating with the NEM blockchain, similar to superblocks, but the contracts are in nodejs… this might be a better approach because you can put all the passwords as environment variables in your server and those would never be seen in practice.

Second, is there any source where we can see how to sign transactions offline? The link that you shared, what they are doing is emulating the behavior of a hardware wallet that will sign the transaction and then a connected device will just make the request to the blockchain.

Thank you so much!



Yes, you are correct. The nem code is in JS and can easily run on a nodejs instance. And yes, the keys should be in env var.

If I remember correctly, the article about the hot/cold wallet shows you how to sign transactions offline and then how to broadcast them. With a quick google search, I found this tool as well.


So I am on Part 5 of the Random Game.

Whenever I Roll, Enter the address and click Save, I get this alert FAILURE_TIMESTAMP_TOO_FAR_IN_FUTURE.

I thought it was my code, but then I tried Filip’s entire code (with my private key, mosaic, and namespace), and I still get this error. Any suggestions?



Make sure that the date, time and timezone are correctly set up on your computer. Try to dial that in as exact as possible and try again. Let me know if it works.


Hey Filip, there is an error in the finished code on github. When you declare “var scores” it should be like this “var scores={};” , in the code it only says “var scores;” what will result in an error when executing the code.

I was also looking in the documentation what exactly the “nem.model.addres.clean” does, but I cannot find it in the documentation of the sdk. It is mentioned but not explained. Is there another resource where I can find additional docs ?


It should be fine to declare vaiables without initializing them. It works for me.

No, the documentation for that sdk is pretty much non existant. But the clean function just makes the string uppercase and removes any hyphens.