Implementing Challenge Solver in other language #23
-
I asked copilot to translate the challenge_solver.rs file and it came up with something. However, I am not sure how this code works; I understand that it needs to work out the nonce that was used given the prefix and the taget_hex by repeatedly hashing the "{prefix}{nonce}" string and comparing it to target. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
You understood it correctly. In short, you must find an unknown The current
Is present in an u8 array as:
For example, the following prefix:
Then the first
Because the sha256 of
Or, in u8 array:
Is smaller than the current So you got the Publish Token with the value For high-level languages like Python, you may just hash it to a hex string and compare the 2 strings directly:
|
Beta Was this translation helpful? Give feedback.
You understood it correctly. In short, you must find an unknown
nonce
so that the the sha256 hash of{prefix}{nonce}
is smaller than thetarget
.The current
target
's hex:Is present in an u8 array as:
For example, the following prefix:
Then the first
nonce
(from zero) that is valid is:Because the sha256 of
k…