[Ethereum] the difference between transaction cost and execution cost in remix

remixsolidity

What is the difference between transaction cost and execution cost as seen after contract instantiation in remix?

Remix

I don't think it matters, but here is my contract:

contract DepositCounter {
    uint deposits = 0;
    function() {
        deposits++;
    }
}

Best Answer

Transaction costs are the costs for sending the contract code to the ethereum blockchain, they depend on the size of the contract.

Check out the source code:

 var getGasUsedOutput = function (result, vmResult) {
        var $gasUsed = $('<div class="gasUsed">');
        var caveat = lookupOnly ? '<em>(<span class="caveat" title="Cost only applies when called by a contract">caveat</span>)</em>' : '';
        if (result.gasUsed) {
            var gas = result.gasUsed.toString(10);
            $gasUsed.html('<strong>Transaction cost:</strong> ' + gas + ' gas. ' + caveat);
        }
        if (vmResult.gasUsed) {
            var $callGasUsed = $('<div class="gasUsed">');
            var gas = vmResult.gasUsed.toString(10);
            $callGasUsed.append('<strong>Execution cost:</strong> ' + gas + ' gas.');
            $gasUsed.append($callGasUsed);
        }
        return $gasUsed;
    };

Execution costs should be really the vm execution costs, if I interprete the parameter vmResult correctly. Is this maybe because a default constructor will be called any way?

Related Topic