Published on

Drizzle Truffle or web3 Handle Bools Strangely

Authors

Today we were trying to get drizzle to communicate with a Solidity method that returned a bool:

function isValid() external view returns (bool) {
    return isValid;
}

We wrote tests for this and confirmed we were getting back a boolean when trying to call this under the correct circumstances. The issue can when we tried to call this from the front-end with Drizzle. We kept getting back the value 0 no matter whether isValid was true or false.

Due to this weird behaviour we decided to rather return a string which behaved as expected:

function isValid() external view returns (string) {
    return isValid; //isValid is now a string
}

As this worked and previously our tests worked the issue seemed to be caused by something in Drizzle or web3 (which Drizzle wraps and uses internally).