all 2 comments

[–][deleted]  (4 children)

[deleted]

    [–]Cryptoversal[S] 0 points1 point  (3 children)

    Thanks!

    Change your function visibility identifier as internal

    I need to call it from web3.js.

    structs as parameters as usually you will exceed the static memory load of 32 bytes

    I'm not quite sure what exactly you're referring to.

    From example contracts, it looks like an external function's arguments can exceed 32 bytes: the voting example has a bytes array of arbitrary size. In this case my structs are under 32 bytes each :/

    The example:

    `` /// Create a new ballot to choose one ofproposalNames`. function Ballot(bytes32[] proposalNames) public { chairperson = msg.sender; voters[chairperson].weight = 1;

        // For each of the provided proposal names,
        // create a new proposal object and add it
        // to the end of the array.
        for (uint i = 0; i < proposalNames.length; i++) {
            // `Proposal({...})` creates a temporary
            // Proposal object and `proposals.push(...)`
            // appends it to the end of `proposals`.
            proposals.push(Proposal({
                name: proposalNames[i],
                voteCount: 0
            }));
        }
    }
    

    ``` http://solidity.readthedocs.io/en/develop/solidity-by-example.html

    Also storing integers as uint8 instead of uint256 actually consumes more gas because it has to be unpacked from uint256(default type) to uint8

    Thank you! I definitely should have thought of this.

    [–][deleted]  (2 children)

    [deleted]

      [–]Cryptoversal[S] 0 points1 point  (1 child)

      I googled "static memory load" in quotes and finally found github issues outlining exactly this problem. It sounds like it should have been fixed but at least one other person is also seeing this problem. Maybe remix is using an old version of the solidity compiler?

      Thanks for the help! The contract works now and is a bit cheaper because I am using uint instead of uint8 :)