Loading...
Loading...
Master blockchain fundamentals including consensus, cryptography, and distributed systems
npx skill4agent add pluginagentmarketplace/custom-plugin-blockchain blockchain-basicsMaster blockchain fundamentals including consensus mechanisms, cryptographic primitives, and distributed systems architecture.
# Invoke this skill for blockchain fundamentals
Skill("blockchain-basics", topic="consensus", depth="intermediate")import hashlib
def verify_merkle_proof(leaf: bytes, proof: list, root: bytes) -> bool:
"""Verify a Merkle proof for inclusion"""
current = leaf
for sibling, is_left in proof:
if is_left:
current = hashlib.sha256(sibling + current).digest()
else:
current = hashlib.sha256(current + sibling).digest()
return current == rootimport hashlib
import struct
def calculate_block_hash(header: dict) -> bytes:
"""Calculate Bitcoin-style block hash"""
data = struct.pack(
'<I32s32sIII',
header['version'],
bytes.fromhex(header['prev_block']),
bytes.fromhex(header['merkle_root']),
header['timestamp'],
header['bits'],
header['nonce']
)
return hashlib.sha256(hashlib.sha256(data).digest()).digest()[::-1]| Pitfall | Issue | Solution |
|---|---|---|
| Finality confusion | PoW is probabilistic | Wait for 6+ confirmations |
| Hash vs encryption | Hashes are one-way | Use proper encryption for secrets |
| Timestamp trust | Miners can manipulate | Use block height for precision |
from eth_account import Account
from eth_account.messages import encode_defunct
message = encode_defunct(text="Hello")
address = Account.recover_message(message, signature=sig)[Beginner] → Hash Functions → Digital Signatures → Transactions
↓
[Intermediate] → Merkle Trees → Consensus → Network Layer
↓
[Advanced] → BFT Protocols → Sharding → Cross-chain# Unit test template
def test_merkle_root():
txs = [b"tx1", b"tx2", b"tx3", b"tx4"]
root = build_merkle_root(txs)
assert len(root) == 32
assert verify_merkle_proof(txs[0], get_proof(0), root)01-blockchain-fundamentalsethereum-developmentsmart-contract-security| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2025-01 | Production-grade with validation, examples |
| 1.0.0 | 2024-12 | Initial release |