How to estimate RAM/CPU/NET cost for your EOS DApp

Quoc Le
Quoc Le
Sep 20, 2018 · 3 min read

How much does it cost to develop an Dapp based EOS? This question is among the initial ones that are being asked when any development projects begins. To those who are new to EOS and really concern about the cost, here are some information for you.

Before talking about how to calculate the resource price, let’s take a general look on the types, usage and allocation of a resources first:

1. Resource types:

There are three types of resources consumed by accounts:

  1. State Storage (RAM)
  2. Bandwidth and Log Storage (Network)
  3. Computation and Computational Backlog (CPU)

2. Resources usuage

  • RAM: Blockchain state storage is information that is accessible from application logic. It includes information such as order books and account balances
  • Network Bandwidth is measured as your average consumption in bytes over the last 3 days. Net bandwidth is temporarily consumed every time you send an action or transaction
  • CPU Bandwidth is measured as your average consumption in microseconds over the last 3 days. CPU bandwidth is temporarily consumed when you send an action or transaction

3. Resource allocation

  • Network, CPU — staking

The Bandwidth and CPU are allocated proportional to the amount of tokens held in a 3-day staking contract. As time goes by, the consumed Network, CPU free up and you can use the same staked tokens again and again

  • RAM — market purchase

You need to purchase it at the Market Price which follows Bancor Algorithm. Unlike CPU and bandwidth RAM doesn’t get freed up automatically. The only way to free it up is to delete data from the account state. Once freed up, the RAM can be sold at the market price.

4. Resource price calculator

RAM Price

To calculate the price we should use Bancor Algorithm → section 3.1

$ cleos -u http://nodes.get-scatter.com:80 get table eosio eosio rammarket                  

RAM price = Connector Balance / (Smart Token’s Outstanding supply × CW)

= 3158350.8754 EOS / 35044821247 RAM = 0.09 EOS/Kib

Connector Balance = quote.balance

Note: There is a wrong in Bancor Protocol’s white paper, CW was not intended to be 50%, Please check here

NET/CPU Price:

These resources depend on block producer. Each producer will be cost with different price. Here is example for eosnewyorkio producer

$ cleos -u https://api.eosnewyork.io/ get account eosnewyorkio

Net Price = (Net Staked / Net Available) / 3

= 900.0000 / (578.4*1024) / 3 = 0.0005 EOS/KiB/Day

CPU Price = (CPU Staked / CPU Available) / 3

= 900.0000/(1.864*60*1000)/3 = 0.0025 EOS/ms/Day

You can check the current resource price here

5. Estimated cost for your DApp

How to calculate RAM?:

Refer: eos/libraries/chain/eosio_contract.cpp

The amount of code = code_size X setcode_ram_bytes_multiplier

In addition:

overhead_per_row_pper_index = 32 + sizeof(key) + row data for all objects which stored in DB

Total:

Ram for Dapp = Amount of code + overhead_per_row_pper_index

How to calculate CPU/NET?

Example: You are plan to build a DApp with 1.000 users, each user take about 5 transaction/per day.

Normally, each transaction take about 200 bytes for Net, 1ms for CPU

It means:

total_cpu_dapp = 1ms*5*1000 = 5 000 ms/day

total_net_dapp = 0.2*5*1000 = 1000 KiB/day

With above price:

Total EOS (CPU+NET) = 1000KiB * 0.0005 EOS/KiB/Day + 5 000 ms/Day *0.0025EOS/ms/Day ~ 13 EOS/day

This post written at EOS Price 5$ on 20 Sep 2018

LecleVietnam

Lecle Vietnam Team Blog

Quoc Le

Written by

Quoc Le

Blockchain Engineer

LecleVietnam

Lecle Vietnam Team Blog

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade