I am trying to figure out what part of a complicated smart contract transaction is responsible for the cost. I was wondering if there is already a tool for that. Ideally it would spit out you are spending this much gas on this kind of opcode or storage op etc. It would be great for writing optimized computation "heavy" smart contracts.
-
1Geth and parity both support transaction tracing, as does remix. It will list out the exact op codes executed, and how much gas was consumed at each step – Raghav Sood Sep 22 '18 at 20:32
-
Can you elaborate a bit more. How do I call this functionality in geth. I've been using ganache so far – Benedikt Bünz Sep 22 '18 at 21:41
-
github.com/ethereum/go-ethereum/wiki/… and ethereum.stackexchange.com/questions/58044/… may help for the meantime. – eth♦ Sep 24 '18 at 5:57
there is another option I'm trying out right now sol-profiler buy the guys at 0x project
Sol-profiler gathers line-by-line gas usage for any transaction submitted through your provider. This will help you find unexpected inefficiencies in parts of your smart contract, and take a data-driven approach to optimizing it.
On Remix, you can view gas estimates by clicking on your contract on the right side, followed by clicking "Details".
From there, you will get many details about your contract, including the gas estimate for each function.