I am just learning solidity and am getting confused by certain applications of the this keyword in functions. The general form of the functions that confuse me is below and the onlyowner modifier only allows the owner of the contract to call the function:

func myfunc() onlyowner {


  • Can this.balance only reference the owner's address's balance?
  • Or can the owner call this function and references another party's address (IE: this == other party's address)?
  • If yes can they do so selectively or only for all addresses associated with the contract?

1 Answer 1


this refers to the contract. So this.balance means the balance of the contract. It never means any other address.

  • Does this have the same effect as setting the contract owner's address in the constructor? Jun 7, 2018 at 15:07
  • I'm not sure what you mean. The this keyword refers to the contract. It's unrelated to any concept like "ownership."
    – user19510
    Jun 7, 2018 at 15:08
  • I misunderstood. My bad. Jun 7, 2018 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.