You just need a method
addUser(name) which adds a newly created user.
The hash can then be calculated by
keccak256() to generate a
Now it depends on the use case how you would like to store it. Maybe a structure of user details or mapping with
uint id =>
As of now, everything is done by account of Ganache.
Yes, that's default. If you are mentioning this, I guess you want only
account or the contract deploy-er to be able to add users.In that case you just need to have a
require(msg.sender==admin) where admin is the guy assigned during contract deploy.
I read your question again. If you are thinking each user on contract will directly have a mapped account.. No! You need to explain more what you want to achieve.
After your comment, it looks like you need to allocate address to user.
TestRPC/Ganache works differently.
These are the default created accounts under YOUR control.You can easily give away the public address of the accounts but that does not solve any purpose.
Why? Because the user should have their own private key to do some kind of transactions.
For this, it totally depends now.The users should and should create their own accounts and give you the public address.This address should now stay with the contract.
But if you still want to do that way and serve as an admin to user, just pick an
an account, say
account. Place it in a local DB (Optionally) that
account is allocated to username
123user. Create a mapping in contract, call the function to assign the address. when you call the function, just pass the address of
account and username. Rest everything follows.
A better way will be to generate