1

just started looking into an Hello World example of solidity into the Remix web IDE. enter image description here

I deployed it on the embedded blockchain on Remix and I was curious on the execution cost field it was returned when calling the greet function on the contract, in particular it says: 24465 gas (Cost only applies when called by a contract)

Why is that the case? Also is it also true that when a User wallet on the Ethereum mainnet calls some (or any) function from a contract it doesn't pay gas costs or is this specific to this (and maybe other) test blockchains?

Thanks

1 Answer 1

1

In the context of Ethereum, "gas" refers to the execution cost of a transaction or a contract function. Every operation that is performed on the Ethereum blockchain requires a certain amount of gas, and the amount of gas consumed by an operation is proportional to the computational resources required to perform that operation.

In the case of the "greet" function that you deployed in the Remix web IDE, the gas cost is only applicable when the function is called by another contract. This is because when a contract calls another contract's function, it uses up some of its own gas to execute the function. However, when a user wallet calls a contract function, the gas cost is paid by the user directly from their wallet, rather than being deducted from the contract's gas balance.

On the Ethereum mainnet, users must pay gas costs when they call contract functions. This is because all transactions on the mainnet, including contract function calls, require computational resources to execute and therefore consume gas. The amount of gas required for a given transaction or function call depends on the complexity of the operation and is determined by the Ethereum network at the time the transaction is processed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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