2

Simple contract, one function.

function getSha256(uint32 nonce) returns (bytes32 hash) {
    return sha256(nonce);
}

> contractInstance.getSha256.call(1);
Error: Error: VM Exception while executing eth_call: stack underflow
  • this may be related to testrpc ot truffle – Badr Bellaj May 30 '17 at 8:49
  • Actually I believe the testrpc issue is the case. The code works fine, but should not be throwing that error. It only happens after I make a back explicit cast and try to run it after making a correction – ArnonRednon May 30 '17 at 11:08
  • open then an issue on their github – Badr Bellaj May 30 '17 at 11:24
  • I haven't cornered the STR exactly yet, ty – ArnonRednon May 30 '17 at 13:29
2

Try adding the constant modifier as follows:

pragma solidity ^0.4.10;

contract Test {
    function getSha256(uint32 nonce) constant returns (bytes32 hash) {
        return sha256(nonce);
    }
}

And here is the Remix screen showing that it works:

enter image description here

If you don't add the constant modifier, you will have to execute your call as a transaction.

See What is the difference between a transaction and a call? for further information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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