Hi Guys, how do you convert the nonce to hex in JS? This question seems to be pretty straight forward, but I found that e.g nonces 1-15 have prefix 0 -> e.g. 01,02,03,04 etc. Then other nonces up to 284 are without the 0 prefix. The nonce 284 is again with zero prefix -> 011c. How do you handle the conversion from simple number?
Convert your decimal into hex - > hexNonce = nonce.toString(16)
Then check if the number of characters is even or odd. If it's odd add a 0.
if hexNonce % 2 !== 0 {
fmtNonce = 0${hexNonce}
}
Convert your decimal into hex - > hexNonce = nonce.toString(16) Then check if the number of characters is even or odd. If it's odd add a 0. if hexNonce % 2 !== 0 { fmtNonce = 0${hexNonce} }