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
BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193

1 Answers1

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.

BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193