Skip to main content
added 323 characters in body
Source Link
Rick Park
  • 3.2k
  • 2
  • 9
  • 25

You can define a function without address:

function showSender() public view returns (address)
{
     return(msg.sender);
 }

AND A SECOND FUNCTION WITH THE SAME NAME with address

 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

They can be at the same time in the same contract without problems or interference. Like this:

contract MyContract {

function showSender() public view returns (address)
{
     return(msg.sender);
 }


 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

}

When your user is calling MyContract.showSender without arguments he hits the first, in the case ofwith address passed he hits the second.

Remain to understand how to generate such calls with/without address passed, but this is another story... 😉

You can define a function without address:

function showSender() public view returns (address)
{
     return(msg.sender);
 }

AND A SECOND FUNCTION WITH THE SAME NAME with address

 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

They can be in the same contract without problems. When your user is calling without arguments he hits the first, in the case of address passed he hits the second.

Remain to understand how to generate such calls with/without address passed, but this is another story... 😉

You can define a function without address:

function showSender() public view returns (address)
{
     return(msg.sender);
 }

AND A SECOND FUNCTION WITH THE SAME NAME with address

 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

They can be at the same time in the same contract without problems or interference. Like this:

contract MyContract {

function showSender() public view returns (address)
{
     return(msg.sender);
 }


 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

}

When your user is calling MyContract.showSender without arguments he hits the first, with address passed he hits the second.

Remain to understand how to generate such calls with/without address passed, but this is another story... 😉

Source Link
Rick Park
  • 3.2k
  • 2
  • 9
  • 25

You can define a function without address:

function showSender() public view returns (address)
{
     return(msg.sender);
 }

AND A SECOND FUNCTION WITH THE SAME NAME with address

 function showSender(address passedAddress) public view returns (address)
  {
     return(passedAddress);
   }

They can be in the same contract without problems. When your user is calling without arguments he hits the first, in the case of address passed he hits the second.

Remain to understand how to generate such calls with/without address passed, but this is another story... 😉