Who Authorized This Transfer?
Follow a signed transaction into a block and see why tampering, replay, and balance violations are rejected.
- Separate a private-key signature, transaction data, and ledger state
- Explain how a nonce prevents replay
- Watch a block change balances and leave a verifiable hash
- PREVIOUSCourse introduction
- CURRENTWho Authorized This Transfer?
Follow a signed transaction into a block and see why tampering, replay, and balance violations are rejected.
- NEXTWhy Do Pending Transactions Queue?
Think about these questions first.
Choose an answer before opening the explanation. You can add anything unexpected to your review list.
Q01Why can a perfectly valid signature still produce a failed transaction?+
A signature only proves an address authorized these bytes. Nonce, balance, gas, contract conditions, and current state are checked during execution; valid authorization is not a valid state transition.
Onchain finance eventually reduces to one question: can every node verify the next state transition from the same previous state? We will start with one transfer instead of memorizing consensus vocabulary.
A transaction is more than “send money”
Each account in the lab has a balance and a nonce. A transaction includes the sender, recipient, amount, and nonce. The signature proves that whoever controls the key authorized this exact set of fields; it does not prove that the account has enough funds, or that the transaction has already been confirmed.
一笔交易如何变成状态?
交易先被签名和广播,再由节点验证并打包进区块。任何一步不满足规则,余额都不会改变。
- Nonce
- 0
- 公钥
- pk_alice_demo
- Nonce
- 0
- 公钥
- pk_bob_demo
- Nonce
- 0
- 公钥
- pk_you_demo
还没有交易。先用正确 Nonce 广播一笔转账。
先看三张账户余额和 Nonce。签名只授权一组具体字段,节点还要在打包时检查 Nonce、余额和状态规则。
还没有区块。交易先在本地 Pending,等节点打包。
- 01
创世状态:三个账户各有 1,000 积分,Nonce 从 0 开始。
Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.
The lifecycle has four distinct steps:
- Sign: the sender signs the transaction fields with a private key.
- Broadcast: nodes place it in a pending pool and verify the signature.
- Include: a block producer selects transactions and executes state transitions in order.
- Confirm: later blocks reference the chain, so replaying the same inputs produces the same result.
A nonce belongs to account state
Without a nonce, the same signed transfer could be broadcast repeatedly. A nonce creates an account-local sequence: an account expecting 0 becomes 1 after a successful execution, and the next valid transaction must use 1.
Try broadcasting a future nonce and mine a block. The transaction is recorded as rejected, while the balance and nonce stay unchanged. A failed attempt may appear in the block index, but it must not become a successful state transition.
A block fixes order and summarizes state
A block is not a magical database write. It records an ordered list of transactions, the previous block hash, and a state root computed after execution. Nodes replay the list: subtract from the sender, add to the recipient, increment the sender nonce, and compute the new state summary.
Expand: how this step works
verify(tx):
check signature(tx.from, tx.fields)
check tx.nonce == account[tx.from].nonce
check account[tx.from].balance >= tx.amount
apply(tx):
account[tx.from].balance -= tx.amount
account[tx.to].balance += tx.amount
account[tx.from].nonce += 1
stateRoot = hash(all accounts and nonces)
Production chains add fees, gas, signature schemes, transaction-pool policies, block proposals, and finality. This lab compresses cryptography into a deterministic signature digest so the state transition remains visible.
The ledger is every other mechanism’s foundation
Collateral in a prediction market, reserves in an AMM, total supply in a token launch, and a finalized oracle result are all state changes applied to a ledger. Once you understand the ledger, you can ask of any mechanism: who authorized this change, can it be replayed, and what should remain unchanged when it fails?
Why is a signed transaction rejected after its amount is changed?
Five questions for reading an onchain transaction
After the lab, explain:
- What does signature verification answer, and what does balance verification answer?
- Why should a nonce advance only after a successful state transition?
- How is a pending transaction different from a confirmed one?
- How does a block commit to transaction order and chain continuity?
- How can a state root reveal that two nodes executed different results?
These questions are the shared entry point for tokens, exchanges, lending, and liquidation. More complex financial mechanisms do not escape the ledger; they add more state and more constraints on top of it.