I have the following contracts:
pragma solidity ^0.4.17;
contract one{
uint firstNum;
uint secondNum;
uint thirdNum;
function getNumber(uint _num, uint _num2,uint _num3) public{
firstNum = _num;
secondNum = _num2;
thirdNum = _num3;
}
}
contract two{
uint firstNum;
uint secondNum;
uint thirdNum;
function getNumber(uint[3] numValues) public{
firstNum = numValues[0];
secondNum =numValues[1];
thirdNum = numValues[2];
}
}
Literally the only difference is the input function. Now for the costs:
Contract one creation:
- Transaction cost: 102814 gas.
- Execution cost: 37682 gas.
and function call 1,2,3 as input:
- Transaction cost: 82106 gas.
- Execution cost: 60258 gas.
Contract two creation:
- Transaction cost: 121264 gas.
- Execution cost: 51500 gas.
and function call [1,2,3] as input:
- Transaction cost: 82296 gas.
- Execution cost: 60448 gas.
So a few questions...why is it more expensive? and now why do contracts like 0x use arrays versus just entering them separately?