Gas and Fees

Sabi wetin separate and Fees for di Injective Chain.

E get one thing for blockchain wey dem dey call Gas. Na like how much power or effort dem machine need use to carry out your transaction for inside the system.

So for Injective Chain, dem dey use this Gas thing to track how much work every transaction dey do. Na like meter wey dey measure how much electricity your house dey use. This transaction things dem like read or write things inside the chain store, you know?

Now, whenever you do something for inside the chain, dem go collect small money from you. Dem calculate this money based on how much Gas your transaction take use. Na like say, the more power your transaction use, the more money dem go collect.

So na that be the koko: Gas na the effort, fee na the money wey you go pay for that effort. Dem two things dey work hand in hand for inside Injective Chain.

fee = gas * gas price

Dis Gas thing no be just for show o! E get two main reasons why dem dey use am. Imagine some transaction wey come dey suck all the power for the whole chain, like hungry lion wey dey finish all the gazelle meat. Gas dey there to stop this kind of thing. Transactions wey take too much Gas go cost too much, so users no go fit fit waste power anyhow. Some bad actors like to send rubbish transactions to block the chain, like throwing sand for everybody eyes. Gas dey there to stop this kind of nonsense too. If dem send rubbish transactions wey use too much Gas, dem go pay plenty money, so e no go sweet them again.

Cosmos SDK Gas

For Cosmos SDK, we dey use two thing know as gas dey waka. We dey use di main GasMeter andBlockGasMeter:

  • GasMeter: Na like your personal fuel gauge for every transaction. It keeps track of how much power your transaction use to change things inside the chain (like writing stuff in the store). Dis meter dey resets after each transaction, so you gats start fresh every time.

  • BlockGasMeter: Na like the big fuel gauge for the whole block. It keeps tabs on how much gas all the transactions in a block use together. And there's a limit to how much gas the whole block can guzzle, na like fuel tank wey no fit full pass a certain level. This limit na agreement wey dem set for the chain (Tendermint consensus parameters), but if everybody agree, dem fit change am anytime.

For more about this gas thing wey dey power Cosmos Chain, you fit check here. Na library wey get plenty details.

Even as transactions be di usual way to change things inside the chain, some Kain things happen wey no need transactions. Dem fit still use power and change stuff too.

Reason am like this - BeginBlock and EndBlock na like morning and evening routine for the whole chain. Dem get small jobs wey dem do before and after every block, just like you fit tidy up your room in the morning and before you sleep. AnteHandler na like security guard wey dey check transactions before dem enter the chain. Dem fit read small things from the store to make sure everything be cool and proper.

These special things, even though dem no be transactions, dem still use gas too.Wetin dey keep track of gas dey monitor all this activity, no be just for transactions alone.

BeginBlock and EndBlock

E get two things wey dey happen for inside the chain, BeginBlock and EndBlock, dem be like morning and evening greetings for the whole system. Every time dem start and finish processing one set of transactions (na like one block), dem go do these special things. You fit call am like "chain maintenance" or "housekeeping" for the whole system.

Now, who tell dem things wetin to do? Na two big senior men wey dey control di chain. One na Tendermint Core, wey be like the main gatekeeper, and the other na Cosmos SDK modules, wey be like different departments wey dey handle different things. These two ogas dey work together to reason wetin go xup for BeginBlock and EndBlock.

AnteHandler

Before any matter even touch the chain, one special guard dey check them first. Na AnteHandler, wey be like the bouncer for the nightclub. He go look at the transaction small small, read some information, and make sure everything set before gree am enter the chain.

Last updated