1

I want to get a return value from current contract call other contract by delegatecall, but got a error of out-of-gas. I try to add gas limit to 3000000000, but it doesn't work. please help me. And i consulted How can I get delegatecall to return data, delegatecall and function return values, but can't find problem. My contract as follows:

pragma solidity ^0.4.13;

contract Core {

    uint balance = 10;

    function getBalance() constant returns (uint){
        return balance;    
    }

}

contract CoreAPI {

    function getBalance() constant returns (uint);

}

contract Shell is CoreAPI{

      CoreAPI core;
      address creator;

      function Shell () {
          creator = msg.sender;
      }

      function upgrade(address _core){
          if (msg.sender != creator) {
              revert();
          }
          core = CoreAPI(_core);
      }

      function getBalance() constant returns (uint response){
          address dest = core;
          bytes4 calldata = bytes4(sha3("getBalance()"));
          assembly {
               let status := delegatecall(gas, dest, add(calldata, 0x20), mload(calldata), 0, 32)
               response := mload(0)
          }
      }

  }

Your Answer

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

Browse other questions tagged or ask your own question.