I have a contract such

contract tokenEvents
    event globalEvent(address contractAddress, string eventName, uint value);
    event globalEvent2(address contractAddress, string eventName, uint value, address senderAddress);

    function callEvent(string eventName, uint value)
        globalEvent(msg.sender, eventName, value);

    function callEvent2(string eventName, uint value, address senderAddress)
        globalEvent2(msg.sender, eventName, value, senderAddress);


Another contract is used to above contract such

    uint amount = msg.value;
    amountRaised += amount;
    tokenEvents te = tokenEvents(0x5488845db957f6fd3691b0c2959b607dc52f09b2); 
    uint nValue;
    address senderAddress;

    if (msg.sender == partyone){
        if (contribution[partyone] == 0)
            contribution[partyone] = amount;
            contribution[partyone] += amount;

        eventName = "party1_contribution";
        nValue = contribution[partyone];
        senderAddress = partyone;

    else if (msg.sender != beneficiary) {
        partytwo = msg.sender;
        if (contribution[partytwo] == 0){
            contribution[partytwo] = amount;
        } else {
            contribution[partytwo] += amount;

        eventName = "party2_contribution";
        nValue = contribution[partytwo];
        senderAddress = partytwo;
    else {
        if (contribution[msg.sender] == 0){
            contribution[msg.sender] = amount;
        } else {
            contribution[msg.sender] += amount;

        eventName = "other_contribution";
        nValue = contribution[msg.sender];
        senderAddress = msg.sender;

    te.callEvent2(eventName, nValue, senderAddress);

Now whenever I send ether some ether to this contract its taking too much gas. For example: 20000

What is the issue?

1 Answer 1


21000 gas is the gas needes for a standard, non-contract transaction. You need to increase the gas based on how much computation is done.

All gas is refunded, so the simplest way to see how much gas is used is make the transaction with 100k gas, go to the TX on etherscan, and see how much gas it ended up using. In the future you can use that amount.

(How do I know how much gas to use when calling a contract?)

  • 21,000 gas is actually the price for a transaction, so you'll never have a transaction succeed at 20,000. May 7, 2016 at 22:59
  • Whoops. You're right. I think I was think about 20 shannon at the same time. Fixed.
    – tayvano
    May 8, 2016 at 3:53

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.