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

better described how gas is used when interacting with a smart contra… #11997

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

stolab
Copy link
Contributor

@stolab stolab commented Jan 22, 2024

Description

Suggestion to better describe how the gas is used when interacting with a smart contract. The documentation say

Gas is required for any smart contract interaction too.

But there is a use case when you don't have to pay any gas when calling a smart contract function.

Related Issue

[Fixes #11989 ]

Copy link

netlify bot commented Jan 22, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 7a490cc
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/66510527d41679000863309b
😎 Deploy Preview https://deploy-preview-11997--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 33 (🔴 down 5 from production)
Accessibility: 92 (no change from production)
Best Practices: 89 (🔴 down 3 from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the content 🖋️ This involves copy additions or edits label Jan 22, 2024
Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @stolab, thanks for this! Sorry for delay. I like the direction of the content you're suggesting, just had a few thoughts on how we could clean it up a bit more. Let me know your thoughts of if you'd like someone else to resume from here. Thanks!

@@ -160,7 +160,9 @@ The base fee will be burned **-0.00399 ETH**

Validator keeps the tip **+0.000210 ETH**

Gas is required for any smart contract interaction too.
In case of an interaction with a smart contract there is 2 cases possible:
1. A `view` or `pure` function (as described in [solidity documentation](https://docs.soliditylang.org/en/v0.8.23/contracts.html#view-functions)) is called from an EOA. In that specific case, no gas will be paid by the caller and the result will be returned. The underlying RPC call for this scenario is [eth_call](https://ethereum.org/en/developers/docs/apis/json-rpc#eth_call)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see where you're going with this but it doesn't seem appropriate for where it is on the page. I might break this into it's own h3 header, ie ### Smart contract interactions {#smart-contract-interactions}

I would probably leave something similar to the comment you deleted as well though, just updated. Maybe "Gas is require for any transaction that alters the state of a smart contract" instead... weaving in the rest of the content.

Also, the link to eth_call should be relative: /developers/docs/apis/json-rpc#eth_call, and consider wrapping the term itself in single-backticks to style it as code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @wackerow, thanks for your feedback, I made changes accordingly.

I agree for the h3 header, but in that case I would suggest to rename the ### On gas {#on-gas} to ### Regular transactions {#regular-transactions}. Let me know what's your opinion is on this

Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stolab Like the updates! Left a few thoughts on some final touches, let me know what you think 😄

public/content/developers/docs/transactions/index.md Outdated Show resolved Hide resolved
public/content/developers/docs/transactions/index.md Outdated Show resolved Hide resolved
public/content/developers/docs/transactions/index.md Outdated Show resolved Hide resolved
stolab and others added 3 commits May 8, 2024 10:08
Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com>
Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com>
Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com>
@stolab
Copy link
Contributor Author

stolab commented May 8, 2024

@wackerow Yes indeed your suggestion sounds much better ! thanks for the suggestion I merged them


Gas is required for any transaction that involves a smart contract.

Smart contracts can also contain functions known as [`view`](https://docs.soliditylang.org/en/latest/contracts.html#view-functions) or [`pure`](https://docs.soliditylang.org/en/latest/contracts.html#pure-functions) functions, which do not alter the state of the contract. As such, calling these functions from an EOA will not require any gas. The underlying RPC call for this scenario is [`eth_call`](/developers/docs/apis/json-rpc#eth_call)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we could simplify this whole thing and say that any attempt at state change requires gas, but reading Ethereum does not.

Copy link
Contributor Author

@stolab stolab May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agree it could be simplified but as this is developer doc I thought it make sense to be a bit more explanatory. And as calling view and pure function internally cost gas I think that make sense to keep the part explaining the difference
However I agree that the underlying RPC call is probably not the most interesting/relevant thing

Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna lean on the side of keeping a bit more detail here given dev docs location; pulling in

@stolab
Copy link
Contributor Author

stolab commented Jun 10, 2024

@wackerow, can we merge it then ? not sure why exactly one check is not successful

@wackerow
Copy link
Member

Oops, apologies @stolab, didn't mean to let this sit. No worries about that check; not required (and a false negative).

@wackerow wackerow merged commit b14db11 into ethereum:dev Jun 14, 2024
5 of 6 checks passed
@wackerow
Copy link
Member

@all-contributors please add @stolab for content

Copy link
Contributor

@wackerow

I've put up a pull request to add @stolab! 🎉

@stolab
Copy link
Contributor Author

stolab commented Jun 14, 2024

@wackerow thanks for your time and the discussion we had on this PR!

This was referenced Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Documentation discussion] Gas cost for smart contract interaction
3 participants