0

Good day,

I know that using a constant function means that no change will be done on the blockchain, but I'd like to have a smart contract that verifies the user input WITHOUT exposing what the input is unless it matches specific criteria. You can see in the following example that no number below 5 should be accepted.

contract Try{

    uint public num;

    function changeNum(uint _num){
        num = _num;
    }

    function cool(uint _num) constant {
        if (_num > 5){
            changeNum(_num + 2);
        }
    }
}

I don't want to use a modifier since it's still possible to produce a signed transaction that will contain an invalid input, it will simply be rejected by the other nodes. I want to have it so that the user will be allowed to insert whichever number they like to the cool function, and only if the number is above 5, a transaction (containing the final input of _num + 2) will be signed and transmitted.

I'll appreciate any input you might have on how to achieve this behavior using only the EVM.

1
  • It is not possible within solidity, you either have a transaction or a call. You cannot change the behavior in the middle of the operation.
    – Ismael
    Commented Sep 26, 2017 at 20:09

1 Answer 1

0

The initial call to cool necessarily must come from either another smart contract or an external account. In either case, anyone can see the call using something like the RPC and web3.0. You can't hide it. (At least, not yet, until we get zk-snarks or something.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.