Im making a website thats going to use a custom token. Im new to developing using eth tokens/coins.

How do I store and access the users tokens?

What Im wondering is do I create additional addresses in my own local wallet (geth) for each user or should they come to the site already having their own wallets from elsewhere?


This is a potentially far-reaching subject because any combination of contracts, clients and servers is possible, each with their own implementation details.

I can provide an introductory conceptual starting point for your thinking using the Minimum Viable Token contract here: https://www.ethereum.org/token

The Smart Contract is designed to track balances for users. In summary, it's a bank. Important thing to realize is msg.sender is always the ethereum address that called the function. This is the user's Ethereum address.

This line:

mapping (address => uint256) public balanceOf;

sets up a namespace using addresses as keys and storing unsigned integers called balanceOf. public means there is a read-only getter function that will require one argument (the address) and return a uint256. Anyone can use that to inquire about anyone's balance.

There's also a function transfer().

Notice that it uses msg.sender to find values stored in balanceOf. In particular, this line is illustrative:

balanceOf[msg.sender] -= _value;

The balance of the msg.sender is reduced by the _value to transfer.

Implicitly, users can only send from their own accounts. A browser-based user interface could tell the user's Ethereum node to send a transaction to the contract. The contract would check for sufficient funds, then move the funds (_value) from the user to the _to address (passed in). The end.

A web server isn't needed in the simple case above. In many cases, a web server may be interested. Ethereum has a facility to inform a web server. An event emitter can be added to the contract. A server can have its own Ethereum node and listen for important events.

Hope it helps.

| improve this answer | |
  • Thanks for the answer. It's helpful, but doesn't quite answer the question. What I'm wondering I guess is how do exchanges provide you with a temporary wallet while you trade? I want to do something like that. Have a temporary wallet that works in the site but you can put your funds back in your permanent wallet when you're done. – Jon Furry Apr 23 '17 at 14:42
  • There's an interface standard called ERC20 that might be helpful. ERC20 helps move coins to/from exchanges. Same interface might be useful for moving funds to/from site, if that's necessary. github.com/ConsenSys/Tokens – Rob Hitchens Apr 23 '17 at 18:11
  • Ok, I figured out what it is im trying to ask about, its how to create and use hot wallets or other wallets that dont need private keys to send and receive funds. – Jon Furry Apr 23 '17 at 20:54

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.