2

I have contract Collector with function sendCoins to external wallet, but some times this function works, sometime not. I have no loops in contract, just one send and that's all - so I thought it should use exactly the same amount each time. Cannot see any difference in calling it. There is no difference in stack, memory etc (only different addresses to withdraw) in debug also.
https://live.ether.camp/transaction/3d1722a1c44f3cfbfb0297257085df2048f4fce1d1fefa966cf38d751517f337/vmtrace#90 https://live.ether.camp/transaction/b989801148749ad598d311187ab71eecffd09ee1022d7bafa8a4fd2f2100d3ac/vmtrace#90


Raw-receipts at ether.camp are seems to be not equal.

So payloads better to see at another site. https://etherchain.org/tx/0x3d1722a1c44f3cfbfb0297257085df2048f4fce1d1fefa966cf38d751517f337 https://etherchain.org/tx/0xb989801148749ad598d311187ab71eecffd09ee1022d7bafa8a4fd2f2100d3ac


pragma solidity ^0.4.2;
/**
 * Contract that will forward any incoming Ether to its creator
 */
contract Forwarder {
  // Address to which any funds sent to this contract will be forwarded
  address public destinationAddress;

  /**
   * Create the contract, and set the destination address to that of the creator
   */
  function Forwarder() {
    destinationAddress = msg.sender;
  }

  /**
   * Default function; Gets called when Ether is deposited, and forwards it to the destination address
   */
  function() payable external{
        if (!destinationAddress.send(msg.value))
            throw;
  }

  /**
   * It is possible that funds were sent to this address before the contract was deployed.
   * We can flush those funds to the destination address.
   */
  function flush() {
    if (!destinationAddress.send(this.balance))
          throw;
  }
}

contract Collector {

    // Address to which any funds sent to this contract will be forwarded
    address owner;
    Forwarder public lastGeneratedAddress;

    // simple single-sig function modifier
    modifier onlyowner { if (msg.sender == owner) _; }

    event logDeposit(address sender, uint amount);

    // this function is executed at initialization and sets the owner of the contract
    function Collector() {
        owner = msg.sender;
    }

    // this function is executed at initialization and sets the owner of the contract
    function newAddress() onlyowner external {
        lastGeneratedAddress = new Forwarder();
    }

    function sendCoins(address receiver, uint amount) onlyowner external{
        if (!receiver.send(amount))
            throw;
    }

    function() payable {
        logDeposit(msg.sender,msg.value);
    }

    /**
     * It is possible that funds were sent to this address before the contract was deployed.
     * We can flush those funds to the destination address.
    */
    function flush() external{
        if (!owner.send(this.balance))
            throw;
    }
}
3

From the yellow paper Appendix G. Fee Schedule:

Gcall       700   Paid for a CALL operation.
Gnewaccount 25000 Paid for a CALL or SUICIDE operation which creates an account.

In your first (successful) transaction you are sending ether to address 78d2...4821 which is already "created" (i.e. has some transactions). So you are paying 700 gas for executing CALL instruction.

But in the second (failed) transaction you are sending ether to address c11b...d675 which is "new" (i.e. does not have any incoming transactions). In this case executing CALL costs 25000 gas.


This distinction was added in response to the DoS attack on the Ethereum network which occurred at the end of 2016. See EIP158 and EIP161 for more details.

Your Answer

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

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