Search code examples
sdkethereumblockchainsmartcontractscryptocurrency

ContractCalls with negative values


a more generic and rather philosophical question:

From your experience with blockchains and SDKs communicating with those blockchains, do you think that the SDK for a given network has to support making ContractCalls with negative values for function parameters to a deployed contract on the network?

Let's say we have the following contract:

contract ReturnDataTypes {
    function returnUint(uint24 count) external pure returns (uint24) {
        return count;
    }

    function returnInt(int24 count) external pure returns (int24) {
        return count;
    }
}

When we are trying to make ContractCall and calling method returnInt(int24 count) with a negative value - e.g. -5. Do we expect the result to be -5 or CONTRACT_REVERTED?


Solution

  • When we are trying to make ContractCall and calling method returnInt(int24 count) with a negative value - e.g. -5. Do we expect the result to be -5 or CONTRACT_REVERTED?

    Since the returned type is a signed integer, the contract might return a negative value, and the SDK should be able to reflect on that.

    If the contract returned expected negative value, but the SDK would not be able to process it, that'd be considered

    • bug in the SDK (undocumented)

    or

    • known issue of the SDK (documented)