I want to create a contract that would produce a hash from a file and have it signed.

Can i put a file through the sha3 using the solidity to get a hash? Or do i have to do it through js?


If I understand your point, you would like to create a service that, given a file, produce its hash and then store it into the Blockchain signing it with relative owner key.

In the blockchain you, as other answer said, doesn't exist any concept of "files" so, if you would like to do this service, you can process your file hash on the local machine and then send the hash to a node that inserts it into the blockchain.

The easiest way to do this is to create a contract with a method insertHash(String hash), that, given a string, adds it to a dynamic array. Then, Javascript side, you can instantiate your contract variable and then contract.insertHash(...) passing your hash, computed by Javascript of your file, as parameter.


Solidity (nor the blockchain) has no concept of 'files' as such. You can't upload a file to the blockchain. I'm also unsure what you mean with "have it signed" - public key cryptography?

You can use byte arrays in Solidity, but depending on the file this may not be possible/feasible. Also SHA3 is definitely not feasible with Solidity. You could use Solidity's keccak functionality to produce a hash if really needed.

It sounds like you really don't need Ethereum for this and it would be a lot easier to do it in JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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