2

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?

tintinthong
  • 143
  • 4

1 Answers1

3

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

Sergi Juanati
  • 3,399
  • 3
  • 17
  • 38