Coding challenge: finding nonce to mine this block

Coding challenge: finding nonce to mine this block

On a coding challenge for a job at Celo:

Find the nonce that mines this block, then enter it above to submit your resume. You can use the following available functions: sha1(str: string): string JSON.stringify(object: Object): string checkHash(hash: string, difficulty: number): bool

const block = { blockNumber: 104413, parentHash: '0x4b1d39aedc8a83b5d87a84a915f66b9cb14e9e36', difficulty: 65536, resumeHash: 'fba689efd74ce23aa105384e720db42b59f1fecb', position: 'Software Engineer', name: 'John Smith', minedBy: 'john@microsoft.com', nonce: 0, }

and i thought the following would work,

target = 0x00ffff0000000000000000000000000000000000000000000000000000 / 65536 hash = sha1(JSON.stringify(block))

while (hash>target){ hash = sha1(JSON.stringify(block)) block.nonce++ }

console.log(block.nonce-1)

But how would the target work in this case? the target that i get would be 64 digit hex while sha1 is only 40 digit hex? Also, what is the significance of blockNumber here?

Sorry about the terrible formatting. The link to the challenge is here. https://celo.org/jobs

http://bit.ly/2HD6owb

Comments

Popular posts from this blog

bitcoin node: what is the difference between simnet and regtest?

How to check if Electrum is masking my IP with the Tor proxy?

Tor proxy on Electrum, what does Port: 9150 and 9050 mean?