0
function chance(string memory str) public view returns (string memory) {
        bytes memory strBytes = bytes(str);
        bytes memory result = new bytes(4);
        for(uint i = 8; i < strBytes.length; i++) {
            result[i-8] = strBytes[i];
        }
        return string(result);
    }

why calling of this function reterns me an error Note: The called function should be payable if you send value and the value you send should be less than your current balance.

how fix this?

2
  • are u sending ether while calling the function?
    – Majd TL
    Sep 22, 2021 at 17:09
  • What's the value of str? An string longer than 12 bytes will make the function revert.
    – Ismael
    Sep 23, 2021 at 4:57

0

Your Answer

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

Browse other questions tagged or ask your own question.