Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function sell(uint amount) returns (uint revenue){
  2. if (balanceOf[msg.sender] < amount ) throw; // checks if the sender has enough to sell
  3. balanceOf[this] += amount; // adds the amount to owner's balance
  4. balanceOf[msg.sender] -= amount; // subtracts the amount from seller's balance
  5. revenue = amount * sellPrice;
  6. if (!msg.sender.send(revenue)) { // sends ether to the seller: it's important
  7. throw; // to do this last to prevent recursion attacks
  8. } else {
  9. Transfer(msg.sender, this, amount); // executes an event reflecting on the change
  10. return revenue; // ends function and returns
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement