0
votes

I am trying to create a smart contract in solidity where I am taking user input from a user which basically is a hash and then I want this hash to be stored on to the smart contract so at the end I could create a function where another user could enter a hash and the program would try to match this hash with the previously stored hash. However, I am not sure how could I store the user's given input on contract?

1
Your question may be more suited to another StackExchange site. For questions related to Bitcoin and other cryptocurrencies, please ask on the Bitcoin StackExchange instead. For questions specific to Ethereum, please ask on the Ethereum StackExchange instead. For further info, please refer to the documentation regarding what is considered on-topic for StackOverflow. - Obsidian Age

1 Answers

1
votes

In Ethereum smart contracts you have state variables which are stored on the blockchain. So to store your hash you can create a bytes32 variable and store your user input hash into it.

Example-:

contract testContract{
   bytes32 public userHashs;

   function userInput(bytes32 _hash)public {
      userHashs = _hash;
   }

}