0

I have created two Contract to separate out storage and validation rules.

ValidationService.sol

pragma solidity ^0.4.16;
import "./Storage.sol";

contract ValidationService {

Storage public store;


 constructor(address add) public{
    store=Storage(add);
 }


 function getMyNumber() public constant returns (uint) {

     return store.getNumber();

 }


}

Storage.sol

pragma solidity ^0.4.16;

contract Storage {

uint public mynum = 5;


  function getNumber() public constant returns (uint) {
    return mynum;
  }

 }

I have called getMyNumber method which called getNumber method of Storage contract and it should return 5 as a output.

validationservice.getMyNumber.call()

The above code is working fine in remix and truffle development environment but it is not working in private blockhain network using Geth.

If i call getNumber method of Storage contract directly from geth console, It's working fine.

Can anyone please guide where is my mistake

1
  • I have found the error in the miner console, after enable verbosity option. Ethereum threw "Invalid opcode 0x3d" error message whenever, I call getMyNumber Method. Please help me if anyone know about this error and how to resolve it.
    – user28326
    Commented Jun 20, 2018 at 9:55

3 Answers 3

2

I have resolved the issue. I have used "byzantiumBlock": 0 into genesis.json file and recreated private blockchain.

For more detail, please refer

Invalid opcode 0x3d

Thanks you all

0

This works fine. The only case in which it won't work is if you are not passing the correct address when deploying validationService.

Hope this helps

1
  • I am passing the correct address. The method has been executed successfully without any error but always returns 0 instead of 5.
    – user28326
    Commented Jun 19, 2018 at 6:06
0

If you are getting below error-

call to ValidationService.getMyNumber errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value. Debug the transaction to get more information. 

then you are using the incorrect address. It would be great if you can share some more information about the error you are facing.

2
  • Method is executed successfully without any error. It returns 0 instead of 5 on Geth console.
    – user28326
    Commented Jun 19, 2018 at 6:07
  • I ran miner using Verbosity level 5 and I have found that, It gave "Invalid opcode 0x3d" error message whenever, I call getMyNumber Method. Please guide me what this error is and how to solve it
    – user28326
    Commented Jun 20, 2018 at 9:51

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.