Error: Returned error: VM Exception while processing transaction: invalid opcode at

by neha agarwal   Last Updated July 11, 2019 13:28 PM - source


pragma solidity ^0.5.1;

    contract ApprovalContract{
    address public sender;
    address payable public reciever;
    address public constant approver=0xe05cE3f89b5Ab28d6d2Ac8A503473Cd5A23e616a;

    function deposit (address payable _receiver)external payable{

        require (msg.value > 0);

    function viewApprover () external pure returns(address) {
        return approver;

    function approve () external payable {

        require (msg.sender==approver);


const ApprovalContract = artifacts.require("ApprovalContract");

module.exports = function(deployer) {

For testing, ApprovalContract.js

const ApprovalContract = artifacts.require('../../lyndacontract/ApprovalContract.sol');


it('initiates contract',async function(){
  const contract = await ApprovalContract.deployed();
  const approver = await; 
  assert.equal(approver,0xe05cE3f89b5Ab28d6d2Ac8A503473Cd5A23e616,"approvers don't match");

truffle compile,truffle migrate run successfully. When I do truffle test,this error comes-

Error: Error: Error: Returned error: VM Exception while processing transaction: invalid opcode
    at (/home/neha/.nvm/versions/node/v8.16.0/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
Truffle v5.0.26 (core: 5.0.26)
Node v8.16.0

Related Questions

Specify address for transaction in truffle test

Updated July 27, 2018 18:28 PM

Contract.deployed() does not work as expected

Updated June 27, 2019 15:28 PM

Evaluate the performance of a smart contract

Updated December 04, 2018 17:28 PM

error in test file in vscode file not found

Updated October 11, 2018 10:28 AM