I want to execute a smart contract function that takes input bool.

Here for example makes the distinction that web3 uses javascript which doesn't consider 1 as true, but solidity does consider 1 as true.

So my question is, if a Write Function in Etherscan takes input bool, say I want to specify True, do I input 1 or true or True?


In Remix:

Whatever you pass to the bool parameter will become true except if you pass the value false.

You can easily check this through a simple contract with Remix:

pragma solidity ^0.8.1;

contract Test {
    function isBool(bool check) external pure returns(bool) {
        if (check) return true;
        else return false;

In Etherscan:

Etherscan seems to accept only the following inputs giving these outputs:

  • Input: true or 1 => returns true
  • Input: false or 0 => returns false

Anything different to these input values is returning:

SyntaxError: Unexpected number in JSON at position 1

Feel free to check it in Ropsten at 0xD394C76C16E7a4a29221218F194A14f6074De6a3

  • what if I pass 0, does that become false too? – tintinthong Mar 1 at 15:48
  • Nop. Passing 0 returns true. 0 is just another number. – Sergi Juanati Mar 1 at 15:49
  • Thanks! You are talking in the context of Etherscan right? 'Im worried I don't know how they parse the inputs. – tintinthong Mar 1 at 15:53
  • Good point. I deployed and verified the contract in Etherscan and apparently the inputs/outputs are slightly different vs. Remix. I'll update my answer. – Sergi Juanati Mar 1 at 15:58

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.