1

i deploy tokens in private net. If i deploy tokens in offical net, how people buy tokens? If they send ether on contract address, they will receives tokens?

For example function buy

function buy() payable {
    uint amount = msg.value / buyPrice;                // calculates the amount
    if (balanceOf[this] < amount) throw;               // checks if it has enough to sell
    balanceOf[msg.sender] += amount;                   // adds the amount to buyer's balance
    balanceOf[this] -= amount;                         // subtracts amount from seller's balance
    Transfer(this, msg.sender, amount);                // execute an event reflecting the change
}

If have payable, people can buy tokens through the wallet, for example myetherwallet?

0

Yes, people can buy token through the wallet, for example MEW.

If you want to test locally:
first connect MEW to your local node, like testrpc (you can read more here "Error: base fee exceeds gas limit" when using the withdrawal pattern);
then click tab Contracts, add your Contract address and ABI/JSON interface; finally, select the buy function, entering the amount of ETH you want to spend.

Hope this help.

3
  • I did, brought out: "invalid sender" – blanry Jul 28 '17 at 3:53
  • Yeah, work. I correctly understood that people through MEW will be able to buy without these actions, just seeing the address of the contract and quantity ETH with Gas? – blanry Jul 28 '17 at 7:34
  • I understand. Need create a unname function. Thank you – blanry Jul 28 '17 at 8:05

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.