0

I'm using Remix IDE to compile a simple contract function. I'm fairly new to Solidity and have tried using different combinations of the compiler version and that of the parser solidity command. The problem still persists.

pragma solidity ˆ0.4.0;
uint storedData;
function set(uint x) public {
    storedData = x;
}
function get() contsant public returns (uint) {
    return storedData;
}
funtion increment (uint n) public {
    storedData = storedData + n;
}
funtion decrement (uint n) public {
    storedData = storedData - n;
}

None of the older answers to similar questions has solved my issue. The error: enter image description here

1 Answer 1

0

The code has a couple of issues:

  • The character before 0.4.0 should be a ^ (Circumflex Accent U+005E), and not ˆ (Modifier Letter Circumflex Accent U+02C6).

  • The functions should be inside a contract NN {}, solc 0.4 doesn't allow standalone functions.

  • There are a few types funtion, contsant.

pragma solidity ^0.4.0;

contract Test {

    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() constant public returns (uint) {
        return storedData;
    }

    function increment (uint n) public {
        storedData = storedData + n;
    }

    function decrement (uint n) public {
        storedData = storedData - n;
    }
}

Your Answer

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

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