Search code examples
blockchainethereum

Why does the deployment of smart contracts on the private Ethereum blockchain need to consume gas fee, while the invocation does not?


Why does the deployment of smart contracts on the private Ethereum chain need to consume gasoline, while the invocation does not?


Solution

  • When you're deploying a contract, you're sending a transaction, effectively storing the contract bytecode in the network. All transactions cost gas fees as a reward for the miner/validator who executes it and publishes it to the network.

    When you're invoking a contract function, you can do it two ways:

    • read-only gas-free call that is not processed by a miner/validator - only by a node that your app is connected to. You don't pay any gas fees, but also cannot store any changes (e.g. token transfers)
    • read-write transaction that costs gas fees as a reward for the miner/validator