I have a simple contract

pragma solidity ^0.4.4;

contract Main {

function getValue() constant returns (bool){
  return true;

I just need to create a web interface that can fetch this value for me.

I unboxed webpack in empty repo by >truffle unbox webpack, deleted the previous contracts, changed the index.html and app.js files, changed the 2_deploy_contracts.js accordingly but the error i get on console of the browser is:

Uncaught (in promise) Error: VM Exception while processing transaction: revert

Here is my index.html and app.js file.


     <title>Truffle 3 Frontend Demo</title>

   <script src="./app.js"></script>
   <script src="../node_modules/web3/dist/web3.js" type="text/javascript">       </script>
   <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" type="text/javascript"</script>

and my app.js file is

import { default as Web3 } from 'web3'
import { default as contract } from 'truffle-contract'
import Main_artifact from '../../build/contracts/Main.json'

const TESTRPC_HOST = 'localhost'
const TESTRPC_PORT = '8545'

function component () {
  var element = document.createElement('div')
  let provider = new Web3.providers.HttpProvider(`http://${TESTRPC_HOST}:${TESTRPC_PORT}`)
  let main = contract(Main_artifact)

  main.deployed().then(function(instance) {

    var s = instance.getValue(); //instance.getValue.call() doesnt work either
    return s;
    element.innerHTML = `value: ${result}`

  return element


1 Answer 1


I believe the problem is the constant keyword on your function.

Per this issue on the solidity repository:

the keyword constant is invalid on functions

Try removing that and redeploying the contract.

  • 1
    Sorry to revert back so late, I did remove it and still got an error, I upgraded my truffle to 4.0.4 from 4.0.1 and surprisingly it worked. I don't know if truffle did it or removing the keyword but it worked. Thanks for helping. Commented Jan 2, 2018 at 16:19

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.