Reputation: 105
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?
Upvotes: 0
Views: 2173
Reputation: 307
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;
}
}
Upvotes: 2