I am trying to execute following function

    function createSurvey() external payable notTheOwner returns(uint surveyId, address newSurveyAddress) {
    require(msg.value > surveyCreationFees);

    uint surveyReward = msg.value.sub(surveyCreationFees);

    address _newSurveyAddress = (new Survey).value(surveyReward)(msg.sender);
    uint _surveyId = surveys.push(_newSurveyAddress).sub(1);
    surveyToOwner[_surveyId] = msg.sender;

    SurveyCreated(_surveyId, _newSurveyAddress);
    return (_surveyId, _newSurveyAddress);

Contract is deployed using account 0 and I am trying to call a function from account 1

I have tried following :

> surveyfactory.createSurvey.call({value: 100, from: web3.eth.accounts[1], to: web3.eth.accounts[0]})

Error: VM Exception while processing transaction: revert at Object.InvalidResponse (/home/zcon/ethereum_voting_dapp/chapter1/node_modules/web3/lib/web3/errors.js:38:16) at RequestManager.send (/home/zcon/ethereum_voting_dapp/chapter1/node_modules/web3/lib/web3/requestmanager.js:61:22) at Eth.send [as call] (/home/zcon/ethereum_voting_dapp/chapter1/node_modules/web3/lib/web3/method.js:145:58) at SolidityFunction.call (/home/zcon/ethereum_voting_dapp/chapter1/node_modules/web3/lib/web3/function.js:135:32)

I have also tried


Complete code of contract is available here

value I am sending is greater than surveyCreationFees
  • I think you want sendTransaction, not call. – user19510 May 3 '18 at 13:59
  • No I have tried sendTransaction, it is also not working – Soham Lawar May 3 '18 at 14:06
  • > surveyfactory.createSurvey.sendTransaction({value : web3.toWei('100000', 'wei') , from : web3.eth.accounts[1]}) Error: VM Exception while processing transaction: revert at Object.InvalidResponse – Soham Lawar May 3 '18 at 14:08
  • Either debug the transaction to see where it's failing or just remove things until it succeeds. (The function is small; it should only take a minute or two to figure out which line is causing the revert. From there it should be easy to debug.) – user19510 May 3 '18 at 14:10

Your Answer

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

Browse other questions tagged or ask your own question.