Is it possible to refer to state variables when a local variable has the same name?

The this keyword in Solidity does something else, and I haven't heard of any equivalent keyword.

For example:

pragma solidity ^0.4.18;

contract escrow {

  address seller;
  address buyer;
  address owner = msg.sender;

  function setup(address seller, address buyer){
    if(msg.sender == owner){
        this.seller = seller;
        this.buyer = buyer;


I found this GitHub issue but no answers to my specific question.

  • This" represents the current contract instance. I'm not sure if what you're seeking is possible. In general, we should avoid writing the same name for two different variables.
    – 6egic
    Jan 28, 2018 at 2:55

1 Answer 1


This doesn't exist in Solidity. What you typically see instead is a leading underscore:

address seller;
address buyer;

function setup(address _buyer, address _seller) {
    buyer = _buyer;
    seller = _seller;

(I assume you didn't mean to write seller twice in your code.)

  • 1
    but this is just a style used to distinct between function arguments and global variables. Is he perhaps requesting for solidity something similar to C++ Scope resolution operator?
    – 6egic
    Jan 28, 2018 at 3:00
  • Sorry, I'll edit my answer to make it clearer. Yes, I believe that's what the original question is asking for, but it doesn't exist in Solidity.
    – user19510
    Jan 28, 2018 at 3:01
  • I can confirm, I haven't seen anything similar either and it would be much easier to just distinct naming wise.
    – 6egic
    Jan 28, 2018 at 3:02

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.