Calculating Gas Fee

Klaytn uses a similar transaction fee model as Ethereum does — Gas. All transactions are required to pay fees in KLAY in order to get accepted and included in blocks.

Quick Recap: KLAY is the main internal transferable token of Klaytn

Gas Fee Calculation

Total gas fee an arbitrary transaction must pay can be calculated as follows:

Total Gas Fee = Gas Price x Gas Used

In Klaytn, gas price is constant which is set to 25 ston. Wait, ston? Not, KLAY? What is ston anyway? Here’s a conversion table you might find helpful.

| Unit | peb value | peb |
|—|—|—|—|
| peb | 1 peb | 1 |
| kpeb | 10^3 peb | 1,000 |
| Mpeb | 10^6 peb | 1,000,000 |
| Gpeb (a.k.a. ston) | 10^9 peb | 1,000,000,000 |
| KLAY | 10^18 peb | 1,000,000,000,000,000,000 |

The above table is a part of the full version available here.

Accodring to the table, 25 ston is 25,000,000,000 peb and equal to 0.000000025 KLAY. Okay, now we can calculate how much gas fee one transaction must pay: you just multiply 25 to the amount of gas the transaction used and divide it by 10^9.

FYI, you can look up your transaction receipt for gas used (with key gasUsed).

Gas Fee Example

Nothing explains better than one good example. So, here’s an example. A simple value transfer transaction takes 21,000 gas. The following calculates the amount of gas fee in KLAY for a value transfer.

1)   Gas Price x Gas Used = Total Gas Fee
2)   25 ston x 21,000 = 525,000 ston
3)   525,000 ston / (10^9 ston/KLAY) = 525 x 10^-6 KLAY = 0.000525

So the gas fee is 0.000525 KLAY. Simple, right?

2개의 좋아요