How to solve VM Exception while processing transaction revert error

0 votes

I am working on truffle and running these codes to run an example:

truffle(development)> var hw  

undefined 

truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;}); 

undefined 

truffle(development)> hw.SayHello.call() 

I am getting the following error:

***Error: VM Exception while processing transaction: revert 

    at Object.InvalidResponse (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:41484:16) 

    at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:328866:36 

    at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:324536:9 

    at XMLHttpRequest.request.onreadystatechange (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:327565:7) 

    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176407:18)  

    at XMLHttpRequest._setReadyState (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176697:12) 

    at XMLHttpRequest._onHttpResponseEnd (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176852:12) 

    at IncomingMessage.<anonymous> (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176812:24) 

    at emitNone (events.js:111:20) 

    at IncomingMessage.emit (events.js:208:7) ***

My code is as follows:

HelloWorld.sol 

        pragma solidity ^0.4.8;

contract HelloWorld { 

   function SayHello() public returns (string) { 

        return ("SomeHello"); 

    } 

} 

2_deploy_contracts.js 

var ConvertLib = artifacts.require("./ConvertLib.sol");

var MetaCoin = artifacts.require("./MetaCoin.sol");

var HelloWorld = artifacts.require("./HelloWorld.sol");

var second = artifacts.require("./second.sol");


module.exports = function(deployer) { 

  deployer.deploy(ConvertLib);

  deployer.link(ConvertLib, MetaCoin); 

  deployer.deploy(MetaCoin); 

  deployer.deploy(HelloWorld);

  deployer.deploy(second);

}; 

My truffle.js 

module.exports = { 

  networks: { 

    development: { 

      host: "localhost", 

      port: 8545, 

      network_id: "*" // Match any network id 

    } 

  } 

};

I am working on Ubuntu 14. How do I solve it?

Jul 26, 2018 in Blockchain by slayer
• 29,370 points
6,494 views

3 answers to this question.

0 votes

Edit your 2_deploy_contract.js file and only keep the following code in it:

var HelloWorld = artifacts.require("./HelloWorld.sol");

module.exports = function(deployer) {   deployer.deploy(HelloWorld); };

Then run your code

$ truffle compile 

Compiling .\contracts\HelloWorld.sol... 

Writing artifacts to .\build\contracts


$ truffle migrate 

Using network 'development'.


Running migration: 2_deploy_contracts.js   

Deploying HelloWorld...   

... 0xef7e895758805a3c3c9aaed7dc7c97fe7b2278b0c0d6ee8105192183a86188c9 

HelloWorld: 0x54329ff919efda7920408084590d7480a6c88243 

Saving successful migration to network...   

... 0x0954625bf66275469c9475ca21f5db20bc4667efb716c5e19bfd98a9553f4a83 

Saving artifacts...


$ truffle console 

truffle(development)> var hw 

undefined 

truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;}); 

undefined 

truffle(development)> hw.SayHello.call() 

'SomeHello' 

truffle(development)>

Note: Always remember to compile and migrate commands before running your code and make sure the testrpc is already running.

answered Jul 26, 2018 by digger
• 26,740 points
0 votes

First, start testrpc. For this, open a terminal and run the following command:

$ testrpc

Next, open a new terminal and compile and migrate the contract:

$ truffle compile
$ truffle migrate
answered Apr 30, 2019 by Vivek
This worked, thanks! I had forget to compile and migrate after making the changes.
0 votes
I am using windows 7. Any solution for windows system?
answered Apr 30, 2019 by Rajesh

You can use the same solutions mentioned in the above answers. And also, you might have to change truffle.js file name to truffle-config.js

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

How to solve Runtime error when querying Hyperledger?

OCI is open container initiative.. The error ...READ MORE

answered Jul 9, 2018 in Blockchain by slayer
• 29,370 points
964 views
0 votes
10 answers

How to solve gradle build failed error?

I migrated the project to a different ...READ MORE

answered Dec 7, 2018 in Blockchain by Rajat
48,976 views
0 votes
1 answer

How to solve "Failed to deserialize creator identity error"?

It seems like the problem is caused ...READ MORE

answered Jul 13, 2018 in Blockchain by slayer
• 29,370 points
1,712 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,461 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,935 views
0 votes
1 answer

How to create a Genesis Block in a Private Network?

{     "nonce": "0x0000000000000042",     "difficulty": "0x000000100",     "alloc": {     },     "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",     "coinbase": "0x0000000000000000000000000000000000000000",     "timestamp": "0x00",     "parentHash": ...READ MORE

answered Jul 12, 2018 in Blockchain by digger
• 26,740 points
2,015 views
0 votes
1 answer
0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 26,740 points
2,449 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP