My friend had made an EOS contract and he has asked me to submit a random uint64, I need to generate this in nodejs.

Do I need to use a library like big number https://www.npmjs.com/package/big-number or or int64 https://github.com/broofa/node-int64 Ive read the docs and i just don't get it?

Do I then need to convert the number to hex before I send it to the contract?

Is there some library that will just give me a random uint64 ready to fire of to an EOS contract?

Would something like this do the job?

var crypto = require('crypto'),
biguint = require('biguint-format')

const myUint64 = biguint(crypto.randomBytes(64), 'hex', { prefix: '0x' }); 

// myUint64 = 0x748eba3cfdc84c0d9ecd86a4878c7291649abee4c93417226af3ed2f31ec6e81c4ebafc770f77eb9aefec1662fc7fbb70e4b855589ef976d1ff88b88652a2262
  • It seems that you generate 64 bytes integer, but uint64_t means 64-bit (8 bytes) integer. If you pass uint64, you don't need to pass in hex string.
    – conr2d
    Jul 13, 2019 at 15:22

2 Answers 2


There are different ways to generate a random uint64/ulong in Javascript like concatenating/multiplying the results of Math.Random() or Math.Floor() or using third-party-libs. But here's not really the right place to ask for these things as it's not directly eos-related.

You need to serialize and sign the whole transaction before you push it through chain to the smart contract. You should take a look at eosjs https://github.com/EOSIO/eosjs and probably look for some tutorials on how to use eosjs as it does all this for you.


It is easy to make a random int. I doubt your question means to make unique int as a value of identifier. If so, I am building a solution by making a sequence in eosio table. What do you think?

I think this package can help. There is a thing I need to finish. I will back to this thread once I get it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.