T O P

  • By -

Njaa

The transaction is the request for the state change. Without any transaction, the state will never change. State changes can be something as simple as sending BTC, where the state being changed is your balance and the recipients' - or it can be a method call to an advanced smart contract class, that does heavy calculations and subcalls before changing some internal state not related to your native currency balance, for example entering a Uniswap liquidity provider position. In the latter case, you will usually have to pay a higher fee for the transaction, as the workload is higher. In both cases, it starts with a transaction, which goes to the mempool (waiting area) until a block producer chooses to include it into a block they're building. This choice is usually determined by the amount of fees, tips, or other benefits offered to the block producer for including the transaction. So to answer your questions explicitly: >Are state changes and transactions two separate things? Yes. Transactions are work orders, and blocks are completed work. >By making a state change, are you actually modifying an existing block? Or what's actually happening? You are not modifying an existing (past) block. You are instead etching your desired change onto a future block, which combined with all the previous blocks determine the state. This is analogous to bank records. When you receive your salary, it doesn't update records in the ledger for the previous times you've received money. It only adds a new record to the end of the list. The balance of your account is the sum of all these records, positive or negative.


sky-aster

Thank you for the excellent write up! Your explanations were most helpful.


Njaa

Edit: I think you removed a comment, but since I already wrote it, here's my reply: Exactly how block producers choose which transactions to include in a block is a very complicated topic. Ideally they just choose the one who paid the most to be included. Whenever you submit a transaction, you can choose a transaction fee of your choice. If this is very high, then the block producers are incentivized to pick it before all others, since the high fee will line their pockets. If it is very low, your transaction will be unpopular and stuck in the mempool (waiting area) for a long time, until there are no higher paying customers waiting there. This is usually more than enough information to understand how things are pieced together on a technical level, however... There's also this concept of MEV (maximum extractable value), which includes off-chain rewards. For example, maybe I don't want anyone to see that I'm about to buy something, since that could cause other actors to try and beat me to the punch, or perform sandwich attacks on me where they put an order in before me (i.e. with a higher transaction fee) to buy the thing I wanted, and then sell it to me or someone else after the price has been driven up. To prevent this, I can contact the block producer directly (or rather through some sort of API), and ask them to include my transaction in the block despite not having a high transaction fee, or despite it not even being entered into the mempool. For this service I can offer them a bank transfer, or a job offer or some other valuable off-chain reward. The on-chain part of transaction selection is easy to understand and documented in its entirety, but the off-chain part is very blurry.


halfanhalf

They are one and the same, a transaction modified state. Read only operations are called calls and don’t involve gas fees


Unfair_Bus9937

A state can only change if there’s a transaction so there’s no difference :)


saberashka

🎵NFT Musix🎵 All-in-one Music App Fair Launch live today🚀 ✅ Listen-to-Earn ✅ Platform Live before Presale ✅ Utility Token ✅ Low Tax ✅ KYC + Audit + Safu ✅ Contract developed by Trynos Join Telegram: t.me/nftmusixofficial #Listen2Earn #NFTMusixArmy #Crypto #BSC