I want to know what make the function below called successfully using web3js and throw " Error: VM Exception while processing transaction: revert" when I call it from another smart contract.

function addVacancy(address sender, bytes32 vacancyId, uint256 incentive) public  {

        Vacancy vacancy = vacancies[vacancyId];
        vacancy.incentive = incentive;
        vacancy.owner = sender;

        emit NewVacancy(vacancyId, incentive, sender );

from another smart contract:

function helpMe () public {
   //this throw an error
firstContract.addVacancy(_sender, vacancyId, _value);

EDIT : helpMe() is receiveApproval()

the methode helpMe () is inside the serviceContract:

contract ServiceContract {
  FirstContract firstContract;
  address owner;

  constructor (address _firstContract,
        address _endorserContract) {
        firstContract = FirstContract(_firstContract);
        owner = msg.sender;

  function receiveApproval(address _sender, uint256 _value,
        address _tokenContract, bytes data) public {

       bytes32 vacancyId = keccak256(data);
            // this cauz the error
            firstContract.addVacancy(_sender, vacancyId, _value);

It's possible you are compiling with byzantium expectations (0.4.22 or higher) and then trying to run it on a node (and chain) that doesn't support byzantium.

You'll get a runtime error when the expected parameters are not returned. This post describes the new return values and problem others are having with common contracts. https://medium.com/@chris_77367/explaining-unexpected-reverts-starting-with-solidity-0-4-22-3ada6e82308c

Hope it helps.

  • I am using truffle for migration and compile, how can I choose the compiler version ? – maroodb Jul 1 '18 at 13:08
  • $ truffle version will reveal. Each version of truffle comes with/dictates the solc version included. Upgrade truffle, if needed, to help align everything. – Rob Hitchens Jul 1 '18 at 19:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.