Web3 Operation
Web3 Operation
Wallet Key Concepts
Mnemonic Phrase (Seed Phrase)
- A human-readable list of words used to generate private keys
- Usually 12 or 24 words (BIP-39 standard)
- Acts as the master backup of a wallet
- Anyone with it can fully control the wallet
Private Key
- A secret cryptographic number
- Used to sign transactions and prove ownership
- Derived from the mnemonic phrase
- Must never be shared
Public Key
- Generated from the private key
- Used to verify transaction signatures
- Safe to share publicly
- Cannot be reversed to get the private key
Wallet Address
- Derived from the public key
- Used to receive assets on the blockchain
- Public and shareable
- Example (Ethereum):
0x...
Relationship
- Mnemonic Phrase → Private Key → Public Key → Wallet Address
From Wallet Transaction to Block Confirmation: Complete Flow
1. Transaction Creation (Wallet Side)
User initiates a transaction in the wallet
- Example: Alice wants to send 1 ETH to Bob
- Wallet generates a transaction object:
1
2
3
4
5
6
7
8{
"from": "AliceAddress",
"to": "BobAddress",
"value": 1 ETH,
"nonce": 5,
"gasLimit": 21000,
"gasPrice": 50 Gwei
} nonce: sequence number to prevent replay attacksgas: transaction fee to compensate miners/validators
Wallet signs the transaction with the private key
- Ensures the transaction is authorized by Alice
- Anyone can verify the signature but cannot forge it
2. Transaction Broadcasting
- Wallet broadcasts the signed transaction to the blockchain network (P2P network)
- Nodes receive the transaction and place it in the mempool (pending transaction pool)
- Transactions in mempool are waiting to be included in a block
- At this stage, the transaction is not yet part of any block
3. Transaction Validation (Nodes / Miners / Validators)
Before packaging into a block, transactions are validated:
- Signature verification → confirms the transaction is from Alice
- Sufficient balance → Alice has enough ETH + gas
- Nonce correctness → prevents duplicate transactions
✅ Only valid transactions are eligible to be included in a block
4. Block Packaging
- Miner/validator selects transactions from the mempool
- Usually prioritizes transactions with higher gas fees
- Creates a new block:
- Contains a list of transactions
- Includes previous block hash
- Constructs a block header:
1
2
3
4
5Block N+1
- PreviousHash: hash(Block N)
- MerkleRoot: hash(all transactions)
- Timestamp: 1673779200
- Nonce: ??? (used in PoW)
- Essentially, the block organizes transactions into a structured format ready for consensus
5. Consensus Phase
Different blockchains use different consensus mechanisms:
a. Proof of Work (PoW, e.g., Bitcoin)
- Miner performs work computation
- Tries different
Noncevalues to find a hash below the target - Successfully mined block is broadcast to the network
b. Proof of Stake (PoS, e.g., Ethereum 2.0)
- Validator is selected as block proposer
- Verifies transaction validity
- Signs the block and broadcasts it
- Other validators vote to finalize the block
Core idea: global agreement on which block is accepted
6. Block Confirmation (On-chain)
- Nodes receive the new block and re-verify transactions and block integrity
- Updates local ledger/state
- Block is appended to the blockchain
- Links to previous block hash
- Transactions in this block are now confirmed
- Wallet can check transaction status:
- “Pending” → “Confirmed after 1/2/3 blocks”
- Confirmed transactions are immutable
7. Summary Flow Diagram (Text Version)
1 | Wallet creates & signs transaction |
Wallet, Node, RPC, and Blockchain Network
1. Wallet
- Manages private keys, public keys, and addresses
- Functions:
- Sign transactions
- Query balances and transaction status
- Interact with blockchain via nodes
- Does not store the blockchain or validate transactions
2. Node
- Computer in the blockchain network holding ledger/state
- Functions:
- Validate transactions and blocks
- Store blockchain data
- Provide RPC interface for wallets and apps
3. RPC (Remote Procedure Call)
- Interface to interact with nodes remotely
- Functions:
- Query account balance
- Broadcast signed transactions
- Retrieve block or transaction info
- Protocols:
- HTTP / HTTPS (JSON-RPC)
- WebSocket (for real-time events)
4. Blockchain Network
- P2P network of nodes
- Nodes sync blocks and transactions
- Wallet accesses the network indirectly via node RPC
5. Wallet-Node-Network Connection
Wallet (UI + Private Key)
|
| RPC/API call
v
Node (Full / Light / Hosted)
|
| P2P network sync
v
Blockchain Network
评论



