Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step by step gas estimation #3

Open
luksgrin opened this issue Oct 2, 2022 · 1 comment
Open

Step by step gas estimation #3

luksgrin opened this issue Oct 2, 2022 · 1 comment

Comments

@luksgrin
Copy link

luksgrin commented Oct 2, 2022

Remix has a fantastic debugger that let's you grab a transaction and allows you to see each opcode EVM executed step by step and so on. My question is: given an arbitrary transaction, is it possible somehow to get the amount of gas spent up to a certain point within the transaction? For example:

contract Test {
    uint256 a;
    uint256 b;
    uint256 c;


    function assignValues(uint256 _a, uin256 _b) external {

        a = _a;
        b = _b;
        c = _a*_b;
    }
}

Is there a way to know how much gas was spent up until b = _b when calling Test.assignValues(4, 7)? I imagine one could get all the EVM opcodes executed up until that point, and then manually adding the gas costs of each opcode... Is there an easier way?

@MatheusDaros
Copy link
Contributor

The source of that info can be found in the famous Ethereum Yellow Paper. You can find a more handy spreadsheet here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants