[Ethereum] How to generate a unique identifier in Solidity

contract-developmentdapp-developmentsolidity

I am making a student registration form and need a unique identifier for them. Are there any methods in Solidity that will give a unique number for every student that registers?

Best Answer

There is no built-in unique id generator in Solidity.

2 ideas:

  • use a counter, uint, and make sure to only increment it
  • use keccak256 hash function on unique data about the student, such as their username or email address
Related Topic