Skip to main content
added 192 characters in body
Source Link

I apologize if it is a simple question. I tried to create a simple contract interaction. I've tried to follow instructions on https://ethereum.stackexchange.com/questions/51760/contract-interaction, docs, and another examples to create a simple contract interaction in solidity 0.5.16. There are two contracts, one is a hello-world contract, called con_H (H of "hello") and owns the helloworld() function. The other one is a contract "A" that calls the helloworld function of con_H. The point is that remix-ide throws an error that I find strange: call to con_A.fun_A1 errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

The code is the following one:

pragma solidity ^0.5.16;

contract con_H {
  function helloWorld() external pure returns (string memory) {
    return "Hello, World!";
  }
}


contract con_A {
    con_H ins_H;
    
    function fun_A1() external view returns (string memory) {
        return ins_H.helloWorld();
    }
}

I've also tried for initial lines of con_A:

contract con_A {
    con_H ins_H = con_H(msg.sender);
    ...
}

with msg.sender address with enough balance of 100 test-ETH.

The only way I manage it to work is deploying aside con_H at a given direction 0x..123 and then force the instance H inside con_A with that exact address: con_H ins_H = con_H(0x..123);

How should be done? suggestions..?

I apologize if it is a simple question. I tried to create a simple contract interaction. I've tried to follow instructions on https://ethereum.stackexchange.com/questions/51760/contract-interaction, docs, and another examples to create a simple contract interaction in solidity 0.5.16. There are two contracts, one is a hello-world contract, called con_H (H of "hello") and owns the helloworld() function. The other one is a contract "A" that calls the helloworld function of con_H. The point is that remix-ide throws an error that I find strange: call to con_A.fun_A1 errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

The code is the following one:

pragma solidity ^0.5.16;

contract con_H {
  function helloWorld() external pure returns (string memory) {
    return "Hello, World!";
  }
}


contract con_A {
    con_H ins_H;
    
    function fun_A1() external view returns (string memory) {
        return ins_H.helloWorld();
    }
}

I've also tried for initial lines of con_A:

contract con_A {
    con_H ins_H = con_H(msg.sender);
    ...
}

with msg.sender address with enough balance of 100 test-ETH.

How should be done? suggestions..?

I apologize if it is a simple question. I tried to create a simple contract interaction. I've tried to follow instructions on https://ethereum.stackexchange.com/questions/51760/contract-interaction, docs, and another examples to create a simple contract interaction in solidity 0.5.16. There are two contracts, one is a hello-world contract, called con_H (H of "hello") and owns the helloworld() function. The other one is a contract "A" that calls the helloworld function of con_H. The point is that remix-ide throws an error that I find strange: call to con_A.fun_A1 errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

The code is the following one:

pragma solidity ^0.5.16;

contract con_H {
  function helloWorld() external pure returns (string memory) {
    return "Hello, World!";
  }
}


contract con_A {
    con_H ins_H;
    
    function fun_A1() external view returns (string memory) {
        return ins_H.helloWorld();
    }
}

I've also tried for initial lines of con_A:

contract con_A {
    con_H ins_H = con_H(msg.sender);
    ...
}

with msg.sender address with enough balance of 100 test-ETH.

The only way I manage it to work is deploying aside con_H at a given direction 0x..123 and then force the instance H inside con_A with that exact address: con_H ins_H = con_H(0x..123);

How should be done? suggestions..?

Source Link

contract interaction error: function should be payable

I apologize if it is a simple question. I tried to create a simple contract interaction. I've tried to follow instructions on https://ethereum.stackexchange.com/questions/51760/contract-interaction, docs, and another examples to create a simple contract interaction in solidity 0.5.16. There are two contracts, one is a hello-world contract, called con_H (H of "hello") and owns the helloworld() function. The other one is a contract "A" that calls the helloworld function of con_H. The point is that remix-ide throws an error that I find strange: call to con_A.fun_A1 errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

The code is the following one:

pragma solidity ^0.5.16;

contract con_H {
  function helloWorld() external pure returns (string memory) {
    return "Hello, World!";
  }
}


contract con_A {
    con_H ins_H;
    
    function fun_A1() external view returns (string memory) {
        return ins_H.helloWorld();
    }
}

I've also tried for initial lines of con_A:

contract con_A {
    con_H ins_H = con_H(msg.sender);
    ...
}

with msg.sender address with enough balance of 100 test-ETH.

How should be done? suggestions..?