1

Just watched this tutorial (you can skip to 18:33 and pause to see what I'm referring to): https://www.youtube.com/watch?v=seU7DykOxfc

enter image description here

So it looks like the magical msg object is available in all the public methods of smart contracts. I noticed that msg.sender points to the address of 1) "self" when being called in a constructor and 2) the "other party" a.k.a. the method caller (another contract) when being called from a public method.

As you can see from the screenshot, the contract has a pointer to the buyer and it calls buyer.send(value). Technically can't it just call that until the buyer has no more money / ether? What's stopping this contract from just calling it with arbitrary numbers and then running away?

1

no it this call "self" when called in constructor it references the address of the person deploying the contract, the "this" keyword is what refrences self.

buyer.send() isnt deducting from the buyer address but on the contrary it is sending to eth to the buyer.

5
  • Oh but there's still a call to sender.send(this.balance). So technically can't I just call sender.send(9999999)? – bigpotato Jul 2 '17 at 13:53
  • The address.send() function is confusing and should IMO be called address.receive() to make clear what it does. sender.send(9999999) sends 9999999 Wei from the contract's balance to the sender. If the contract doesn't have enough funds this fails. – SCBuergel Jul 2 '17 at 14:10
  • o... but either way, lets say i'm the seller. can't i call seller.send(999) a lot of times and deduct a bunch of money from the buyer's account? – bigpotato Jul 2 '17 at 14:15
  • The money always comes out of the contract's balance, so you can only send as much ETH as the contact poses – Tjaden Hess Jul 2 '17 at 19:18
  • @TjadenHess is right. – coderwithattitude Jul 4 '17 at 15:17

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.