0

I created a erc20 contract with a total supply of 40,000,000. 10 mil was sent to my wallet and 30 mil suppose to go to investors.

When someone invest, how can I send him tokens from my contract to his erc20 wallet?

Thanks.

1

There is no such thing as ERC20 wallet, unless you have created your own.

The smart contract of your ERC20 token is a place where all tokens are and they are not travelling to other contracts and wallets. The way someone can actually have a number of tokens is just the the mapping usually called balances in which by query balances[address] you can receive amount of tokens this particular address hold.


When someone invest, how can I send him tokens from my contract to his erc20 wallet?

You just update the state by executing something like:

balances[addr_of_investor] = amount_of_tokens;
| improve this answer | |
  • Where do I do that? balances[addr_of_investor] = amount_of_tokens; – Soher Jan 19 '18 at 19:04
  • 1
    You will have to add this functionality to your contract, as it was just an example. For further read I suggest payable functions, fallback functions. – Roman Frolov Jan 19 '18 at 19:15
  • @Soher No, you don't. – Roman Frolov Jan 19 '18 at 20:21
  • Can I fix it if its already verified contract? – Soher Jan 19 '18 at 20:26
  • If the contract is deployed you can’t change it, but you still can make changes in your code and deploy a new one. – Roman Frolov Jan 19 '18 at 20:27

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.