Suppose your contract has a very simple function, F()
, which takes about 1,000 gas
to process. Suppose you want to call that function 100 times. Since there is an overhead of about 21,000 gas
per transaction, you'll be paying 2,200,000 gas
. But, if your contract has a function:
function Fs(uint n){
for (uint i=0; i<n; ++i)
F();
}
You could perform the exact same operation with a single call, Fs(100)
, which would cost only 121,000 gas
, a 94.5% reduction. Is there any way to send several calls to F
in a single transaction, so you can achieve the same effect even when the contract didn't specifically optimize for it?