The following code snippet is designed to forward all funds to a single destination, but where multiple contract D's will exist, allowing differentiation of the original source of the funds.

pragma solidity ^0.4.11;

contract D {
  // (Deployed address of contract E)
  address public _e = 0x63636a7c969A0cF64395d302d3dA0C7CbcF37036; 

  function () payable {

contract E {
  event DepositReceived(address receiverAddress, uint256 amount);
  address public destination = 0x14d06788090769f669427b6aea1c0240d2321f34;
  function deposit(address receiver) payable {
    DepositReceived(receiver, msg.value);

Using delegatecall currently the transaction results in an error and any ETH sent to contract D remains trapped there, as seen here: https://kovan.etherscan.io/vmtrace?txhash=0x4f608dfca2ebed0c51423fb357d13f199f117ce38bcb5001e127c5162f2ae287&type=parity

I am assuming it is failing because any ETH sent to contract D remain there and cannot be forwarded on by contract E via delegatecall. Is this functionality possible using delegatecall at all - ideally i would add delegatecall.value(msg.value) or something similar but this does not seem to be supported.

(I am aware this could be done in other ways, but was hoping to use delegatecall partly to experiment with it and also because this will be part of a larger contract)

Thank you

Your Answer


Browse other questions tagged or ask your own question.