Contracts calling other contracts



  • Hello,

    I'm unable to call contract functions from another contract. The returns are empty, while they work fine on Remix.

    I'm just wondering if that's a current limitation of QTUM network, but that's hard to believe as there are several deployed DAPPs around. It's really unlikely that any of them dispose of inter-contract calls, as it creates a big development limitation.

    Can anyone please tell me that I'm wrong?

    Thanks!


  • qtum team

    Which version of the Solidity compiler are you using? We currently do not support some of the latest opcodes for returning dynamic length data. If you are using that feature in Solidity then it will either have behavior as you experienced, or the contract will crash with an invalid opcode exception



  • Hi,

    From this github issue I was told to change compiler version to homestead, as I did.

    I have created two simple contracts to test the case:


    ContractA.sol

    pragma solidity ^0.4.24;

    contract ContractA{

    function sayHi() public pure returns(bytes10){
        return "Contract A";
    }
    

    }


    ContractB.sol

    pragma solidity ^0.4.24;

    contract ContractA{

    function sayHi() public pure returns(bytes10);
    

    }

    contract ContractB{

    function listenHi(address contractAAddress) public pure returns(bytes10){
        ContractA contractA = ContractA(contractAAddress);
        
        return contractA.sayHi();
        
    }
    

    }


    I have compiled both with the suggested configuration:

    solc --bin --asm --evm-version homestead ContractA.sol
    solc --bin --asm --evm-version homestead ContractB.sol

    I used the bytecodes to create the following contracts on Testnet:

    ContractA: a0160e7e93a323c07f50979717d7c9e3e5964037
    ContractB: a7f4c9e920196ced3c2b269a8bf8b8188450084d

    When calling ContractA.sayHi, the result is as below:

    https://imgur.com/OwYxKht

    When calling ContractB.listenHi, the result is as below:

    https://imgur.com/7HmaXuz

    So I'm still unable to catch the return from another contract, even after compiling to homestead and changing the datatype to bytes10.

    Could you please shed some light on what I could be missing?

    Thanks in advance.



  • Hey, thanks for the support. I managed to make it work by compiling it in Remix with version 0.4.21.



  • @paulofelipe84

    Great, glad you got the help you needed!


Log in to reply
 

Looks like your connection to QTUM was lost, please wait while we try to reconnect.