Search code examples
ethereumsolidityremixtrontronbox

How to add null in text input if user does not enter any address


    function deposit(address payable referrer) public payable whenNotPaused
    {  
    
    }

In my case I need insert address, otherway I will get: "{"reason":"invalid address","code":"INVALID_ARGUMENT","arg":"","coderType":"address","value":""}"

Is there any way if user not enter any text, can add my own text in Solidity?

This box is marked as required, but I want as not required.

I used shasta.tronscan.org .

In my JS no problem, but if user use directly then need to use from code Solidity.

Thanks


Solution

  • I'm trying to understand your question.
    Are you want to use default parameters?

    Well, Solidity does not support default parameters, but it is on their roadmap (see https://github.com/ethereum/solidity/issues/232). To work around this, just use function overloading:

    function deposit() public payable whenNotPaused{  
        address referrer = 0x.....   // use your default parameter.
        //Your code
    
      }
    
    function deposit(address payable referrer) public payable whenNotPaused {  
        // Your Code
        }