Search code examples
ethereumblockchainsoliditysmartcontractsdecentralized-applications

Understanding Decentralized App Costs on Ethereum


I'm diving into the world of decentralised applications on the Ethereum blockchain and I'm excited about the possibilities it offers. As the owner of a company venturing into this space, I want to ensure I have a solid grasp on the financial considerations involved. While I understand that deploying a smart contract and storing data incur costs in the form of gas, I'm looking to expand my knowledge beyond these basics.

Here's what I already have on my radar:

  1. Smart Contract Deployment Costs: I'm aware that deploying a smart contract involves gas fees, which can vary based on the complexity of the contract and network congestion.

  2. Data Storage Costs: Storing data on the blockchain, such as product details or voting records, incurs costs due to the space it occupies.

However, I'm curious about the costs associated with reading data from the blockchain:

  • Is accessing and reading data, such as listing all products, free of charge? Or does it also involve gas fees?
  • If there are gas fees associated with reading data, how does this impact scalability? For instance, if a significant number of users simultaneously query the list of products, would the gas costs become substantial?

I understand this might be a basic question, but I'm striving to grasp the bigger picture and ensure I make informed decisions for my company's decentralized application. Your insights and experiences would be highly appreciated!

Thank you in advance for helping me navigate these considerations and build a better understanding of the costs involved in Ethereum-based decentralized applications.


Solution

  • Is accessing and reading data, such as listing all products, free of charge? Or does it also involve gas fees?

    Anyone can run an Ethereum node. Ethereum node stores the whole state of the Ethereum Virtual Machine. You can query your local node with JSON-RPC for any present or past Ethereum transaction and state.

    The cost of reading from the node is your cost of running the node and scaling it up.

    However most of people use paid RPC nodes as a service for this.

    Thus, the cost of running Dapp is the cost of running the whole Ethereum locally/remotely.

    If there are gas fees associated with reading data, how does this impact scalability? For instance, if a significant number of users simultaneously query the list of products, would the gas costs become substantial?

    Not a gas cost, but the scaling cost is the same as for any web application. More reads, more users -> more web servers and more sharded database you are going to need.

    Note that the original Bitcoin (and Ethereum) vision was that all users run their own node locally. However this turned out to be fantasy as running the node it technically very advanced and hardware demanding. Low-end VPS cannot run Ethereum node, you need a server with fast directly attached SSD storage.

    For transaction costs (writing to the blockchain), these are pushed to the user. When user interacts with your Dapp they pay the gas fees. The gas fees are credited on the block producer, who includes the transaction that modifies the state of your Dapp smart contract in a new block. Because this is a bit clunky there is now something called EIP-1559 account abstraction proposal coming up which would make it possible for a third party (wallet, Dapp) to pay the gas fees. However this is not yet reality today.