ethereum / ethereum-org

[ARCHIVED] ethereum.org website from 2016-2019. See https://github.com/ethereum/ethereum-org-website for current version.
GNU Lesser General Public License v3.0
407 stars 1.39k forks source link

Token Example Error #893

Open ccconnor opened 6 years ago

ccconnor commented 6 years ago

Hello, I'm trying to learn smart contract according to https://www.ethereum.org/token. I'm using remix IDE, and the enviroment option is JavaScript VM. The contract is deployed succefully, but when I try to buy tokens, remix shows errors "the constructor should be payable if you send value". After I added payable keyword, the buy function still failed. The code I'm using is just the same as the above url shows, or https://gist.github.com/6d78ad3e351cb8799339d99a9c3def51. Can someone offer any suggestions?

ccconnor commented 6 years ago

By the way, when value is less than sellPrice, "buy" succeeded, when eual or large, failed. https://monosnap.com/file/LWGKLZCdZNAiDj3nfrdKZzsmy4GrH3

yann300 commented 6 years ago

buyPrice is by default 0, this is why the tx fails, try calling setPrices before

ccconnor commented 6 years ago

First thanks for you reply. But I've already set price.

Aniket-Engg commented 5 years ago

@heyconnor Have you got it worked?

ccconnor commented 5 years ago

@Aniket-Engg Finally I didn't use buy and sell interface.

Aniket-Engg commented 5 years ago

Okay. Your gist is broken. Are you still looking to get it worked?

ccconnor commented 5 years ago

@Aniket-Engg That gist was the same as official site's. I used a simple one.