Lesson 0112 min
SIGNATURE · NONCE · STATE

Who Authorized This Transfer?

Follow a signed transaction into a block and see why tampering, replay, and balance violations are rejected.

OBJECTIVESAfter this lesson, you should be able to:
  • 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
COURSE POSITIONStep 1 of 4
  1. PREVIOUSCourse introduction
  2. CURRENTWho Authorized This Transfer?

    Follow a signed transaction into a block and see why tampering, replay, and balance violations are rejected.

  3. NEXTWhy Do Pending Transactions Queue?
BEFORE YOU READ

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?
SHORT ANSWER

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.

Compared with your prediction:

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.

LEDGER SIMULATION虚拟积分 · 无真实密钥
LEDGER 001 · SIGN / VERIFY / APPLY

一笔交易如何变成状态?

交易先被签名和广播,再由节点验证并打包进区块。任何一步不满足规则,余额都不会改变。

当前链高#0TIP GENESIS
待打包交易0Pending
你的 Nonce0下一个可用序号
已确认0Included
被拒绝0Rejected
最终性高度#00 个区块等待
账户状态余额 + Nonce 是可验证状态
Nonce
0
公钥
pk_alice_demo
Nonce
0
公钥
pk_bob_demo
Nonce
0
公钥
pk_you_demo
交易队列0 TXS

还没有交易。先用正确 Nonce 广播一笔转账。

观察提示

先看三张账户余额和 Nonce。签名只授权一组具体字段,节点还要在打包时检查 Nonce、余额和状态规则。

链上区块0 BLOCKS

还没有区块。交易先在本地 Pending,等节点打包。

节点事件1 EVENTS
  1. 01

    创世状态:三个账户各有 1,000 积分,Nonce 从 0 开始。

ACTION HISTORYExperiment timeline
1 state snapshots

Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.

Initial state
View experiment records →

The lifecycle has four distinct steps:

  1. Sign: the sender signs the transaction fields with a private key.
  2. Broadcast: nodes place it in a pending pool and verify the signature.
  3. Include: a block producer selects transactions and executes state transitions in order.
  4. 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?

KNOWLEDGE CHECK

Why is a signed transaction rejected after its amount is changed?

Five questions for reading an onchain transaction

After the lab, explain:

  1. What does signature verification answer, and what does balance verification answer?
  2. Why should a nonce advance only after a successful state transition?
  3. How is a pending transaction different from a confirmed one?
  4. How does a block commit to transaction order and chain continuity?
  5. 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.

LESSON RECAPComplete the exercise and knowledge check first