0

I have begun using Remix IDE and need clarification on some of its outputs

1) Why is x treated as a function? why would it require any gas?

2) Why are there outputs for constructor and c.bar() only when I have several functions?

3) I created the contract once Opera (The first time), and second time in Chrome. The second time in chrome it only shows logs for constructor creation as pending nothing else.

4) Why is anything being sent to bar at this point? All I did was create the contract ... How about the other functions. Why is nothing showing up in logs for them?

contract c {

uint public x;
function foo(uint a) {
    x = a;
}

function bar(uint a) {
    uint i = 0;
    while (i < a) {
        i++;
    }
}

function zoo() {
    uint j = 0;
    while (j < 1000)
    {
        j++;
    }
}

    //    "Creation": {
    //    "codeDepositCost": "71600",
    //    "executionCost": "118",
    //    "totalCost": "71718"
    // },
     // "External": {
    //     "bar(uint256)": "infinite",
    //     "foo(uint256)": "20222",
        //     "x()": "408",
     //     "zoo()": "infinite"
     // }


}

********* LOG OUTPUT *******************

creation of c pending... [vm] from:0xca3...a733c, to:c.(constructor), value:0 wei, data:0x606...a0029, 0 logs, hash:0x8e5...ab811 Details Debug status 0x1 Transaction mined and execution succeed contractAddress 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c to c.(constructor) gas 3000000 gas

transaction cost 147006 gas execution cost 71718 gas hash 0x8e556bcf671c29461ef9e0b44f1c49ace6b9ba6c8ae6704da417919981aab811 input 0x6060604052341561000f57600080fd5b6101668061001e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630423a132146100675780630c55699c1461008a5780632fbebd38146100b35780637b6a8777146100d6575b600080fd5b341561007257600080fd5b61008860048080359060200190919050506100eb565b005b341561009557600080fd5b61009d61010a565b6040518082815260200191505060405180910390f35b34156100be57600080fd5b6100d46004808035906020019091905050610110565b005b34156100e157600080fd5b6100e961011a565b005b60008090505b818110156101065780806001019150506100f1565b5050565b60005481565b8060008190555050565b60008090505b6103e8811015610137578080600101915050610120565b505600a165627a7a72305820accd4f4e85aa44072ae9331019aea8211a2d953a87e46fa585c9fd30444c97ca0029 decoded input {} decoded output - logs [] value 0 wei

transact to c.bar pending ... [vm] from:0xca3...a733c, to:c.bar(uint256) 0x692...77b3a, value:0 wei, data:0x042...00000, 0 logs, hash:0x98a...c11b1 Details Debug transact to c.bar pending ... [vm] from:0xca3...a733c, to:c.bar(uint256) 0x692...77b3a, value:0 wei, data:0x042...00000, 0 logs, hash:0x0b7...36e52 Details Debug status 0x1 Transaction mined and execution succeed from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c to c.bar(uint256) 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a gas 3000000 gas

transaction cost 21604 gas execution cost 204 gas hash 0x0b7b61daee4d9c0f0f00022d450a3722bff68a06c0d9d635c0e12c8a82b36e52 input 0x0423a1320000000000000000000000000000000000000000000000000000000000000000 decoded input { "uint256 a": "0" } decoded output {} logs [] value 0 wei


Second Run of Contract In Chrome Browser:

LOGS
creation of c pending... [vm] from:0xca3...a733c, to:c.(constructor), value:0 wei, data:0x606...80029, 0 logs, hash:0x9af...05ae9 Details Debug status 0x1 Transaction mined and execution succeed contractAddress 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c to c.(constructor) gas 3000000 gas

transaction cost 147006 gas execution cost 71718 gas hash 0x9af36e631baeb178ac6a8d08a67fddd5edc54c70155f1a2470c94ae46aa05ae9 input 0x6060604052341561000f57600080fd5b6101668061001e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630423a132146100675780630c55699c1461008a5780632fbebd38146100b35780637b6a8777146100d6575b600080fd5b341561007257600080fd5b61008860048080359060200190919050506100eb565b005b341561009557600080fd5b61009d61010a565b6040518082815260200191505060405180910390f35b34156100be57600080fd5b6100d46004808035906020019091905050610110565b005b34156100e157600080fd5b6100e961011a565b005b60008090505b818110156101065780806001019150506100f1565b5050565b60005481565b8060008190555050565b60008090505b6103e8811015610137578080600101915050610120565b505600a165627a7a72305820940b0d92dc192dfa8d541cbe20802fe54e57b341bc2c3bb0ad0dde7574ed54d80029 decoded input {} decoded output - logs [] value 0 wei

0

1) Since x is public, you have a function to access it. View http://solidity.readthedocs.io/en/develop/contracts.html#getter-functions for more info

2 & 4) As far as i can tell, after the contract is created, a transaction is sent to the bar function. The Chrome execution seem correct.

The functions not displayed in logs are the expected behavior, you should check the ABI generated and see all the functions correctly listed

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.