Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sell(uint amount) returns (uint revenue){
- if (balanceOf[msg.sender] < amount ) throw; // checks if the sender has enough to sell
- balanceOf[this] += amount; // adds the amount to owner's balance
- balanceOf[msg.sender] -= amount; // subtracts the amount from seller's balance
- revenue = amount * sellPrice;
- if (!msg.sender.send(revenue)) { // sends ether to the seller: it's important
- throw; // to do this last to prevent recursion attacks
- } else {
- Transfer(msg.sender, this, amount); // executes an event reflecting on the change
- return revenue; // ends function and returns
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement