0

So I've been building a smart contract where users can register and store their projects at. I'm wondering if the gas usage of functions within my contract is acceptable or not ( I'm new to solidity :) ).

Here's the current Gas Cost of my Smart Contract functions:

  • Registration: 92k+ Gas
  • Project Creation: 177k+ Gas

Is there a tool (like eth gas station) that shows real-time Gas usage per contract function call?

0

You can use Remix to test that: http://remix.ethereum.org/

Just paste your contract in place of the default one you will see. Your contract will be compiled automatically. On the right side choose "Run" tab, then choose JavaScript VM for environment and deploy your contract with "Create" button. Buttons allowing to interact with your contract's functions will apear below.

Trigger the function you want to test and in the middle section of the page, at the bottom, you will see info if your transaction succeeded and two buttons: "Details" and "Debug". Click "Details" and there you will find what was the gas cost of your transaction.

Image below shows how to find this window with "Details" and "Debug" if it is not visible by default.

enter image description here

| improve this answer | |
  • Thanks for the answer Mike! But I think you misunderstood the question. I know how to get the Gas Cost of my own transactions. What I'm asking is if there's a tool that we can see the average gas cost of transactions running on the main network so that I can compare mine – wbt_ Apr 20 '18 at 9:13
  • Oh, ok, then in fact I misunderstood it. There are charts for gas price and average transaction cost, but most of the transactions on the main net are simple value transfers between EOS accounts I believe, so I am not sure if it would make much sense to use that data to decide whether your functions are ok. – Mike A. Clearance Apr 20 '18 at 9:36
0

I don't think there are standards about gas-usage of functions, and it wouldn't make sense, except for maybe functions part of standards like ERC20 or ERC773.

Without code, it's hard to tell if it's acceptable or not. It's up to you to try to minimise the writing from zero to non-zero in storage, which is expensive, try to reduce the use of expensive operations, etc...

| improve this answer | |
0

Perhaps you might wanna share your code with us so we can see if 92k for Registration and 177k for Project Creation whether it is worth. It all depends on what kind of logic you need to happen, the more code and state changes you add the higher the gas price will be.

However I wrote article where I compare the gas price when dealing with some basic logic like working with strings, arrays, conditions and so on. You can check it out here - https://www.linkedin.com/pulse/solidity-smart-contracts-how-gas-greedy-miroslav-nedelchev/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.