2

I'm currently trying to develop my knowledge further on lower level calls such as DELEGATECALL.

I am continiously running into when trying to use .delegatecall():

RunTime Error: out of gas
Gas Usage: 0xe07e44(Decimal = 14712388)

delegateCall contract:

 pragma solidity ^0.4.4;
 import "delegateReceiever.sol";

contract delegateCall{
uint public testInt;
address public sender;

function delegateCall(){
    testInt = 1;
}

function delegateCallC(address _c, uint _testInt){
if(_c.delegatecall(bytes4(sha3("setTestInt(uint")),_testInt ))
throw;
}  
}

delegateReceiever contract:

pragma solidity ^0.4.4;
contract delegateReceiever{
uint public testInt;

function delegateReceiever(){
    testInt = 2;
}

function setTestInt(uint _testInt){
    testInt = _testInt;
}
}

Edited truffle deploy to increase gas like so:

deployer.deploy(contract,{gas:114712388})

Edited testrpc initial account balance to:

1e+167

Edited truffle.js file to include gas:

rpc:{
   host: "localhost",
   port: 8545,
   gas: 114712388
}

Is there any other method of ensuring gas will not run out? For example, is there a developer parameter that requires no gas etc..?

1
  • For my own learning, is "setTestInt(uint" missing a closing parentheses on purpose? Aug 9, 2018 at 11:26

1 Answer 1

4

delegatecall returns true on success, so

if(_c.delegatecall(bytes4(sha3("setTestInt(uint")),_testInt ))
    throw

will throw if the call is successfull.

Try

if(!_c.delegatecall(bytes4(sha3("setTestInt(uint")),_testInt ))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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