[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AMJFDC9A3JYPZWYP3KJDQ1":3,"skill-same:01M7AMJFDC9A3JYPZWYP3KJDQ1":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7AMJFDC9A3JYPZWYP3KJDQ1","blockchain-smart-contract-development",null,"Use when writing or reviewing smart contracts. Covers the EVM execution model, gas and storage, EVM-compatible vs EVM-equivalent chains, Solidity and the alternatives (Vyper, Huff, Yul), contract architecture (upgradeability and proxies, access control, design principles), the token and application standards (ERC-20\u002F721\u002F1155\u002F4626, account abstraction and ERC-4337), and DeFi primitives — AMMs, lending, oracles, flash loans, and MEV.","the-vibey-project\u002Fvibey","the-vibey-project","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F329298758?v=4","01M7AJHGZ9722CTJ4JNQZVRH0Q","the vibey project","01M7AJHGZVMG2K7TGXQ6XFHVG3",5,"MIT","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fcryptocurrency-development\u002Fskills\u002Fblockchain-smart-contract-development\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: blockchain-smart-contract-development\ndescription: \"Use when writing or reviewing smart contracts. Covers the EVM execution model, gas and storage, EVM-compatible vs EVM-equivalent chains, Solidity and the alternatives (Vyper, Huff, Yul), contract architecture (upgradeability and proxies, access control, design principles), the token and application standards (ERC-20\u002F721\u002F1155\u002F4626, account abstraction and ERC-4337), and DeFi primitives — AMMs, lending, oracles, flash loans, and MEV.\"\n---\n\n# Blockchain Development: EVM, Solidity, Contract Architecture, Standards, and DeFi\n\n> **Part 2 of 4** of the *Cryptocurrency and Blockchain Development* reference (plugin `cryptocurrency-development`), covering §4–§8. Sibling skills: `blockchain-protocol-layer` (§0–§3 and §11–§12), `blockchain-security-testing-and-ops` (§9–§10 and §13), `blockchain-reference` (§14–§19). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §16 → `blockchain-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — cryptography, distributed systems, or a security lesson the industry\n>   has paid for repeatedly. Does not expire.\n> - **[VERSIONED]** — protocol state, client versions, tooling, upgrade schedules. Moving\n>   fast; verify before relying on it.\n> - **[CONTESTED]** — genuine technical or design disagreement.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that lose money irreversibly. This domain has an\n> unusually direct mapping from bug to financial loss, so those boxes carry more weight\n> here than in an ordinary engineering reference.\n>\n> **Scope note:** this is an engineering document. It covers how these systems are built\n> and how they fail. **It is not investment advice, and does not evaluate any asset as an\n> investment.**\n>\n> **The three framings that organize everything below:**\n> 1. **Deployed code is adversarial code running in public with money attached.** Every\n>    function is callable by anyone, in any order, at any time, composed with contracts\n>    that don't exist yet, by attackers who read your source and have unlimited attempts.\n>    This is a fundamentally harsher environment than ordinary software.\n> 2. **You cannot patch it.** Immutability is the point and also the problem. Upgradeability\n>    is a design decision with its own large attack surface (§6), and \"we'll fix it in the\n>    next release\" is not available to you.\n> 3. **The expensive failures are boring.** Not exotic cryptography — **access control,\n>    business logic, and stolen keys.** §10 → `blockchain-security-testing-and-ops`'s data is unambiguous on this, and it should\n>    reorder your security priorities.\n\n---\n\n## §4. The EVM\n\n### 4.1 The execution model\n\n**[DURABLE]** A **stack machine** (1024-deep, 256-bit words) with four data locations, and\nunderstanding the distinction between them is the single most load-bearing piece of EVM\nknowledge:\n\n| Location | Persistence | Cost | Notes |\n|---|---|---|---|\n| **Stack** | Transient | Cheapest | 1024 slots, 256-bit words |\n| **Memory** | Per-call | Cheap, **expands quadratically** | Byte-addressed scratch space |\n| **Storage** | **Permanent, on-chain** | **Very expensive** | 256-bit → 256-bit map per contract |\n| **Calldata** | Read-only input | Cheap to read | Cheaper than memory for large read-only args |\n| **Transient storage** (EIP-1153) | Cleared at end of tx | Cheap | `TSTORE`\u002F`TLOAD` — reentrancy guards, callbacks |\n\n**[DURABLE] Storage dominates gas cost.** A cold `SLOAD` is ~2100 gas, a zero→nonzero\n`SSTORE` is ~20,000, and a nonzero→nonzero write ~2900 (with refunds for clearing).\n**Almost all gas optimization is really storage-access optimization**, and everything else\nis noise by comparison.\n\n**Call types**: `CALL` (new context, `msg.sender` = caller), **`DELEGATECALL`** (⚠️\n**executes target code in the caller's storage context** — the basis of proxies (§6.1)\nand of some of the worst bugs in the field's history), `STATICCALL` (read-only, reverts on\nstate change), and `CREATE`\u002F`CREATE2` (the latter gives deterministic addresses from a\nsalt, enabling counterfactual deployment).\n\n**Reverts** unwind all state changes in the frame and refund remaining gas. **[DURABLE]\nThe atomicity of a transaction is your most powerful safety property** — if any part\nreverts, none of it happened. Design around it.\n\n### 4.2 Gas\n\n```\ntx cost = 21,000 base\n        + calldata (4 gas\u002Fzero byte, 16\u002Fnon-zero)\n        + execution opcodes\n        + storage (dominant)\n  fee   = gas_used × (base_fee + priority_fee)   [EIP-1559; base fee is BURNED]\n```\n**⚠️ Gas is a security parameter, not just a cost.** Unbounded loops over user-controlled\narrays are a **denial-of-service vulnerability** — if the array grows past the block gas\nlimit, the function becomes permanently uncallable, potentially locking funds forever.\n\n**The 63\u002F64 rule** (EIP-150): a call forwards at most 63\u002F64 of remaining gas, so the caller\nalways retains enough to handle the return. **⚠️ This makes \"gas griefing\" possible** — a\ncallee can deliberately consume its allocation to make the caller fail.\n\n### 4.3 EVM-compatible vs. EVM-equivalent\n\n**[DURABLE] The distinction matters when porting.** \"EVM-compatible\" chains may differ in\nopcode behaviour, gas costs, precompiles, block time assumptions, and `block.timestamp`\nsemantics. **\"EVM-equivalent\"** claims byte-for-byte identical execution. **⚠️ Never assume\na contract audited on mainnet is safe on another EVM chain without re-review** — different\ngas schedules alone can turn safe code into a DoS.\n\n---\n\n## §5. Solidity and the Contract Languages\n\n### 5.1 Solidity\n\n**[VERSIONED] The 0.8.x line is current** — **0.8.36 (July 2026)** was the latest stable at\nthe time of writing, with 0.8.37 in nightly development. Releases are frequent and often\ncarry security fixes; **0.8.36 alone included two medium-severity security fixes.**\n\n**[DURABLE] Pin an exact compiler version in production.** Use `pragma solidity 0.8.30;`\nrather than `^0.8.0`. Floating pragmas mean your deployed bytecode depends on whoever\ncompiled it, which breaks reproducible builds and verification.\n\n**What 0.8 changed and why it matters**: **arithmetic overflow and underflow revert by\ndefault** since 0.8.0. This eliminated an entire vulnerability class — and it's why\n**contracts still running on 0.6.x and 0.7.x are a live risk**. One 2026 exploit hit a\ncontract on **Solidity 0.6.10, which lacks automatic overflow protection**, after nearly\nfive years deployed. `unchecked { }` opts out where you've proven safety and want the gas.\n\n**The essentials**:\n```solidity\n\u002F\u002F SPDX-License-Identifier: MIT\npragma solidity 0.8.30;\n\ncontract Example {\n    \u002F\u002F visibility: external | public | internal | private  — always explicit\n    \u002F\u002F state mutability: pure | view | payable | (default)\n    \u002F\u002F storage vs memory vs calldata — declare deliberately\n\n    error InsufficientBalance(uint256 available, uint256 required); \u002F\u002F custom errors:\n                                                                    \u002F\u002F cheaper than strings\n    event Transfer(address indexed from, address indexed to, uint256 value);\n        \u002F\u002F `indexed` → topics, filterable by log queries; max 3 indexed params\n\n    modifier onlyOwner() { if (msg.sender != owner) revert Unauthorized(); _; }\n\n    receive() external payable {}   \u002F\u002F plain ETH transfers\n    fallback() external payable {}  \u002F\u002F unmatched calldata\n}\n```\n**⚠️ `msg.sender` vs `tx.origin`**: **never use `tx.origin` for authorization.** It's the\noriginal EOA, so any contract the user calls can relay a call to you and pass the check.\nThis is a textbook phishing vector.\n\n**`viaIR`** (the IR-based codegen pipeline) produces better optimization and is increasingly\nthe default in serious projects; enable it deliberately and re-test, since it changes\ngenerated code. **Yul** is the intermediate language, and **inline assembly** drops to it —\nuse sparingly, and know that **assembly bypasses Solidity's safety checks entirely**.\n\n### 5.2 The alternatives\n\n**Vyper** — deliberately restricted, Python-like, no inheritance, no inline assembly,\nbounded loops. **[CONTESTED]** Its restrictions are a real security argument; against it,\na smaller ecosystem and its own compiler-bug history (a Vyper reentrancy-guard compiler bug\ncaused a major 2023 exploit — **the compiler is part of your trust surface**).\n**Huff \u002F Yul** — near-assembly, for extreme gas optimization. Very high risk.\n**Fe**, **Sway** (FuelVM), **Cairo** (Starknet), **Move** (Aptos\u002FSui — resource-oriented,\nwith a genuinely different and interesting ownership model), **Rust** (Solana, CosmWasm,\nNEAR).\n\n---\n\n## §6. Contract Architecture\n\n### 6.1 Upgradeability\n\n**[CONTESTED, and it's the most consequential architectural decision you'll make.]**\n*For upgradeability*: bugs are otherwise unfixable, requirements change, and migrations are\nbrutal for users. *Against*: it reintroduces trust, adds a large attack surface, and\n**upgrade keys are themselves a top-tier target.**\n\n**The patterns:**\n```\nTransparent Proxy    proxy DELEGATECALLs to impl; admin calls handled at proxy\nUUPS (EIP-1822)      upgrade logic lives in the IMPLEMENTATION — cheaper,\n                     ⚠️ but you can brick it by deploying an impl without upgrade logic\nBeacon               many proxies read one beacon → upgrade all at once\nDiamond (EIP-2535)   multi-facet routing; powerful, complex, contested\nImmutable            no upgrade path. The safest and least forgiving option\n```\n> **⚠️ GOTCHA — the proxy failure modes, all of which have caused real losses:**\n> 1. **Storage collisions.** The implementation's storage layout must be append-only across\n>    upgrades. Reordering or inserting a variable corrupts state. Use **namespaced storage\n>    (ERC-7201)** or storage gaps.\n> 2. **Uninitialized implementation contracts.** The logic contract must have its\n>    initializer disabled (`_disableInitializers()`), or someone else initializes it and,\n>    with UUPS, can `selfdestruct`\u002Fbrick it.\n> 3. **Constructors don't run** in proxy context. Use `initialize()` with an\n>    initializer guard.\n> 4. **`immutable` and constructor-set state** live in the implementation's code, not the\n>    proxy's storage — a frequent source of subtle wrongness.\n> 5. **The upgrade key is the whole security model.** A timelock plus a multisig is the\n>    minimum for anything holding real value.\n\n### 6.2 Access control\n\n**[DURABLE] This is the highest-value section in the document, because access control is\nthe single largest category of on-chain loss (§10.1 → `blockchain-security-testing-and-ops`).**\n\nPatterns: `Ownable` (simple, single point of failure), `Ownable2Step` (**use this instead** —\ntransfer requires acceptance, preventing a typo'd address from permanently orphaning the\ncontract), `AccessControl` (role-based), timelocks (mandatory delay on privileged actions,\ngiving users time to exit), and multisig (Safe is the standard) or full DAO governance.\n\n**The checklist for every privileged function**: is it actually restricted? Is the modifier\npresent on *every* path including the initializer and the upgrade function? Can it be\ncalled before initialization? Is the role transferable, and safely? Is there a timelock on\nanything that can drain or brick the system?\n\n### 6.3 Design principles\n\n**[DURABLE]** **Checks-Effects-Interactions** — validate, then update your state, *then*\nmake external calls. This ordering alone prevents most reentrancy. **Pull over push** for\npayments — let users withdraw rather than pushing funds, so one reverting recipient can't\nblock everyone. **Fail loudly** — revert with custom errors rather than returning false.\n**Minimize privileged surface.** **Emit events for everything** an off-chain system needs\n(§13.4 → `blockchain-security-testing-and-ops`). **Bound every loop.** **Handle the ERC-20 misbehaviours** in §7.1.\n\n---\n\n## §7. Standards\n\n### 7.1 Tokens\n\n| Standard | What |\n|---|---|\n| **ERC-20** | Fungible tokens. ⚠️ See below |\n| **ERC-721** | NFTs. `safeTransferFrom` invokes a receiver hook — **a reentrancy vector** |\n| **ERC-1155** | Multi-token, batch operations |\n| **ERC-4626** | Tokenized vaults. ⚠️ **Inflation\u002Fdonation attacks on the first depositor** are the classic bug — mitigate with virtual shares or a dead-shares seed |\n| **ERC-2612** | `permit` — gasless approvals via signature |\n| **ERC-777** | ⚠️ Hooks caused real reentrancy exploits. **Largely deprecated in practice** |\n\n> **⚠️ GOTCHA — ERC-20 is a standard that many tokens don't follow, and assuming compliance\n> is how integrations break:**\n> - **Non-standard return values** — USDT and others don't return a bool. **Use\n>   OpenZeppelin's `SafeERC20`.**\n> - **Fee-on-transfer tokens** — the amount received ≠ the amount sent. **Measure balance\n>   before and after**, don't trust the argument.\n> - **Rebasing tokens** — balances change without transfers.\n> - **Non-18 decimals** — USDC has 6. Hardcoding 18 is a recurring, expensive bug.\n> - **Blocklists** — USDC\u002FUSDT can freeze addresses, so a transfer can revert forever.\n> - **Approval race** — some tokens require setting the allowance to 0 before changing it.\n> - **Malicious tokens** — if you let anyone list a token, you've let them run arbitrary\n>   code inside your callstack.\n\n### 7.2 The rest\n\n**ERC-165** (interface detection), **EIP-712** (typed structured signing — what makes\nsignature prompts human-readable; ⚠️ **always include a domain separator with `chainId` and\nthe verifying contract, or your signature is replayable across chains and contracts**),\n**ERC-1271** (contract signature validation — necessary for smart accounts),\n**ERC-7201** (namespaced storage layout, §6.1).\n\n### 7.3 Account abstraction\n\n**[VERSIONED] The most consequential UX change in years, and it landed in two pieces.**\n**ERC-4337** implements smart accounts entirely outside the protocol — UserOperations,\na Bundler, an EntryPoint, and Paymasters (which enable sponsored gas and paying fees in\nERC-20). **EIP-7702** (shipped in **Pectra, May 2025**) went further by letting a regular\nEOA temporarily execute as a smart contract, so **existing wallets** gain batching, session\nkeys, sponsored gas, and social recovery **without migrating to a new address**.\n\n**⚠️ EIP-7702 is a live security consideration, not just a feature.** An EOA delegating to\nmalicious code is a new and effective drainer pattern, and wallet and contract code that\nassumes \"`msg.sender` with no code is a plain EOA\" is now making an unsafe assumption.\n\n---\n\n## §8. DeFi Primitives and MEV\n\n### 8.1 The building blocks\n**AMMs** (constant product `x·y=k`; concentrated liquidity; the **impermanent loss** that\nLPs bear), **lending** (over-collateralization, health factors, liquidation incentives),\n**stablecoins** (fiat-backed, over-collateralized crypto-backed, and algorithmic — ⚠️ the\nlast category has an extensive failure history), **derivatives**, and **liquid staking**.\n\n**[DURABLE] Composability is the superpower and the risk.** Contracts calling contracts\ncalling contracts means your protocol's safety depends on dependencies you don't control,\nand a bug three layers down can drain you.\n\n### 8.2 Oracles\n\n**[DURABLE] Oracle manipulation is a top-tier exploit class, and the fix is well known.**\n```\n⚠️ NEVER:   price = reserve1 \u002F reserve0      \u002F\u002F spot price from a DEX pool\n                                              \u002F\u002F — a flash loan moves it in one tx\n✓  INSTEAD: Chainlink \u002F Pyth \u002F RedStone push or pull feeds\n            TWAPs over a meaningful window\n            multiple independent sources with deviation checks\n```\nAnd check the feed's own health: staleness (`updatedAt`), the L2 sequencer uptime feed,\nand sane min\u002Fmax bounds. **⚠️ A stale oracle reading treated as current is itself an\nexploit** — several protocols have lost funds this way without any manipulation at all.\n\n### 8.3 Flash loans\n\nUncollateralized loans that must be repaid in the same transaction. **[DURABLE] Flash loans\nare not the vulnerability — they are the capital amplifier that makes an existing\nvulnerability profitable.** They turn \"an attacker with $100M could do this\" into \"anyone\ncan do this, right now, for a fee.\" **Assume every attacker has unlimited capital for one\ntransaction**, and your threat model becomes correct.\n\n### 8.4 MEV\n\n**[DURABLE]** Maximal Extractable Value — profit from ordering, inserting, or censoring\ntransactions. **Front-running**, **back-running**, **sandwich attacks** (the one that\ndirectly harms ordinary users), **liquidations** and **arbitrage** (arguably beneficial).\n\n**Mitigations for builders**: slippage limits and deadlines on every swap (**a swap with no\nslippage bound is free money for a sandwicher**), commit-reveal schemes, batch auctions,\nprivate mempools\u002Forder flow, and designing so ordering doesn't matter.\n\n**The infrastructure**: proposer-builder separation currently runs through **out-of-protocol\nrelays** (MEV-Boost), which is a real centralization dependency — **which is precisely what\nGlamsterdam's ePBS (§3.2 → `blockchain-protocol-layer`) is intended to bring in-protocol.**\n","# Blockchain Development: EVM, Solidity, Contract Architecture, Standards, and DeFi\n\n> **Part 2 of 4** of the *Cryptocurrency and Blockchain Development* reference (plugin `cryptocurrency-development`), covering §4–§8. Sibling skills: `blockchain-protocol-layer` (§0–§3 and §11–§12), `blockchain-security-testing-and-ops` (§9–§10 and §13), `blockchain-reference` (§14–§19). Section numbers are shared across the set; a reference written as §N → `skill` points into that sibling skill.\n>\n> **Currency:** Verified August 2026. See §16 → `blockchain-reference` for the currency snapshot and what goes stale first.\n\n> **How to read this.** Reference, not tutorial. Sections are independent. Three markers:\n> - **[DURABLE]** — cryptography, distributed systems, or a security lesson the industry\n>   has paid for repeatedly. Does not expire.\n> - **[VERSIONED]** — protocol state, client versions, tooling, upgrade schedules. Moving\n>   fast; verify before relying on it.\n> - **[CONTESTED]** — genuine technical or design disagreement.\n>\n> **⚠️ GOTCHA** boxes mark the mistakes that lose money irreversibly. This domain has an\n> unusually direct mapping from bug to financial loss, so those boxes carry more weight\n> here than in an ordinary engineering reference.\n>\n> **Scope note:** this is an engineering document. It covers how these systems are built\n> and how they fail. **It is not investment advice, and does not evaluate any asset as an\n> investment.**\n>\n> **The three framings that organize everything below:**\n> 1. **Deployed code is adversarial code running in public with money attached.** Every\n>    function is callable by anyone, in any order, at any time, composed with contracts\n>    that don't exist yet, by attackers who read your source and have unlimited attempts.\n>    This is a fundamentally harsher environment than ordinary software.\n> 2. **You cannot patch it.** Immutability is the point and also the problem. Upgradeability\n>    is a design decision with its own large attack surface (§6), and \"we'll fix it in the\n>    next release\" is not available to you.\n> 3. **The expensive failures are boring.** Not exotic cryptography — **access control,\n>    business logic, and stolen keys.** §10 → `blockchain-security-testing-and-ops`'s data is unambiguous on this, and it should\n>    reorder your security priorities.\n\n---\n\n## §4. The EVM\n\n### 4.1 The execution model\n\n**[DURABLE]** A **stack machine** (1024-deep, 256-bit words) with four data locations, and\nunderstanding the distinction between them is the single most load-bearing piece of EVM\nknowledge:\n\n| Location | Persistence | Cost | Notes |\n|---|---|---|---|\n| **Stack** | Transient | Cheapest | 1024 slots, 256-bit words |\n| **Memory** | Per-call | Cheap, **expands quadratically** | Byte-addressed scratch space |\n| **Storage** | **Permanent, on-chain** | **Very expensive** | 256-bit → 256-bit map per contract |\n| **Calldata** | Read-only input | Cheap to read | Cheaper than memory for large read-only args |\n| **Transient storage** (EIP-1153) | Cleared at end of tx | Cheap | `TSTORE`\u002F`TLOAD` — reentrancy guards, callbacks |\n\n**[DURABLE] Storage dominates gas cost.** A cold `SLOAD` is ~2100 gas, a zero→nonzero\n`SSTORE` is ~20,000, and a nonzero→nonzero write ~2900 (with refunds for clearing).\n**Almost all gas optimization is really storage-access optimization**, and everything else\nis noise by comparison.\n\n**Call types**: `CALL` (new context, `msg.sender` = caller), **`DELEGATECALL`** (⚠️\n**executes target code in the caller's storage context** — the basis of proxies (§6.1)\nand of some of the worst bugs in the field's history), `STATICCALL` (read-only, reverts on\nstate change), and `CREATE`\u002F`CREATE2` (the latter gives deterministic addresses from a\nsalt, enabling counterfactual deployment).\n\n**Reverts** unwind all state changes in the frame and refund remaining gas. **[DURABLE]\nThe atomicity of a transaction is your most powerful safety property** — if any part\nreverts, none of it happened. Design around it.\n\n### 4.2 Gas\n\n```\ntx cost = 21,000 base\n        + calldata (4 gas\u002Fzero byte, 16\u002Fnon-zero)\n        + execution opcodes\n        + storage (dominant)\n  fee   = gas_used × (base_fee + priority_fee)   [EIP-1559; base fee is BURNED]\n```\n**⚠️ Gas is a security parameter, not just a cost.** Unbounded loops over user-controlled\narrays are a **denial-of-service vulnerability** — if the array grows past the block gas\nlimit, the function becomes permanently uncallable, potentially locking funds forever.\n\n**The 63\u002F64 rule** (EIP-150): a call forwards at most 63\u002F64 of remaining gas, so the caller\nalways retains enough to handle the return. **⚠️ This makes \"gas griefing\" possible** — a\ncallee can deliberately consume its allocation to make the caller fail.\n\n### 4.3 EVM-compatible vs. EVM-equivalent\n\n**[DURABLE] The distinction matters when porting.** \"EVM-compatible\" chains may differ in\nopcode behaviour, gas costs, precompiles, block time assumptions, and `block.timestamp`\nsemantics. **\"EVM-equivalent\"** claims byte-for-byte identical execution. **⚠️ Never assume\na contract audited on mainnet is safe on another EVM chain without re-review** — different\ngas schedules alone can turn safe code into a DoS.\n\n---\n\n## §5. Solidity and the Contract Languages\n\n### 5.1 Solidity\n\n**[VERSIONED] The 0.8.x line is current** — **0.8.36 (July 2026)** was the latest stable at\nthe time of writing, with 0.8.37 in nightly development. Releases are frequent and often\ncarry security fixes; **0.8.36 alone included two medium-severity security fixes.**\n\n**[DURABLE] Pin an exact compiler version in production.** Use `pragma solidity 0.8.30;`\nrather than `^0.8.0`. Floating pragmas mean your deployed bytecode depends on whoever\ncompiled it, which breaks reproducible builds and verification.\n\n**What 0.8 changed and why it matters**: **arithmetic overflow and underflow revert by\ndefault** since 0.8.0. This eliminated an entire vulnerability class — and it's why\n**contracts still running on 0.6.x and 0.7.x are a live risk**. One 2026 exploit hit a\ncontract on **Solidity 0.6.10, which lacks automatic overflow protection**, after nearly\nfive years deployed. `unchecked { }` opts out where you've proven safety and want the gas.\n\n**The essentials**:\n```solidity\n\u002F\u002F SPDX-License-Identifier: MIT\npragma solidity 0.8.30;\n\ncontract Example {\n    \u002F\u002F visibility: external | public | internal | private  — always explicit\n    \u002F\u002F state mutability: pure | view | payable | (default)\n    \u002F\u002F storage vs memory vs calldata — declare deliberately\n\n    error InsufficientBalance(uint256 available, uint256 required); \u002F\u002F custom errors:\n                                                                    \u002F\u002F cheaper than strings\n    event Transfer(address indexed from, address indexed to, uint256 value);\n        \u002F\u002F `indexed` → topics, filterable by log queries; max 3 indexed params\n\n    modifier onlyOwner() { if (msg.sender != owner) revert Unauthorized(); _; }\n\n    receive() external payable {}   \u002F\u002F plain ETH transfers\n    fallback() external payable {}  \u002F\u002F unmatched calldata\n}\n```\n**⚠️ `msg.sender` vs `tx.origin`**: **never use `tx.origin` for authorization.** It's the\noriginal EOA, so any contract the user calls can relay a call to you and pass the check.\nThis is a textbook phishing vector.\n\n**`viaIR`** (the IR-based codegen pipeline) produces better optimization and is increasingly\nthe default in serious projects; enable it deliberately and re-test, since it changes\ngenerated code. **Yul** is the intermediate language, and **inline assembly** drops to it —\nuse sparingly, and know that **assembly bypasses Solidity's safety checks entirely**.\n\n### 5.2 The alternatives\n\n**Vyper** — deliberately restricted, Python-like, no inheritance, no inline assembly,\nbounded loops. **[CONTESTED]** Its restrictions are a real security argument; against it,\na smaller ecosystem and its own compiler-bug history (a Vyper reentrancy-guard compiler bug\ncaused a major 2023 exploit — **the compiler is part of your trust surface**).\n**Huff \u002F Yul** — near-assembly, for extreme gas optimization. Very high risk.\n**Fe**, **Sway** (FuelVM), **Cairo** (Starknet), **Move** (Aptos\u002FSui — resource-oriented,\nwith a genuinely different and interesting ownership model), **Rust** (Solana, CosmWasm,\nNEAR).\n\n---\n\n## §6. Contract Architecture\n\n### 6.1 Upgradeability\n\n**[CONTESTED, and it's the most consequential architectural decision you'll make.]**\n*For upgradeability*: bugs are otherwise unfixable, requirements change, and migrations are\nbrutal for users. *Against*: it reintroduces trust, adds a large attack surface, and\n**upgrade keys are themselves a top-tier target.**\n\n**The patterns:**\n```\nTransparent Proxy    proxy DELEGATECALLs to impl; admin calls handled at proxy\nUUPS (EIP-1822)      upgrade logic lives in the IMPLEMENTATION — cheaper,\n                     ⚠️ but you can brick it by deploying an impl without upgrade logic\nBeacon               many proxies read one beacon → upgrade all at once\nDiamond (EIP-2535)   multi-facet routing; powerful, complex, contested\nImmutable            no upgrade path. The safest and least forgiving option\n```\n> **⚠️ GOTCHA — the proxy failure modes, all of which have caused real losses:**\n> 1. **Storage collisions.** The implementation's storage layout must be append-only across\n>    upgrades. Reordering or inserting a variable corrupts state. Use **namespaced storage\n>    (ERC-7201)** or storage gaps.\n> 2. **Uninitialized implementation contracts.** The logic contract must have its\n>    initializer disabled (`_disableInitializers()`), or someone else initializes it and,\n>    with UUPS, can `selfdestruct`\u002Fbrick it.\n> 3. **Constructors don't run** in proxy context. Use `initialize()` with an\n>    initializer guard.\n> 4. **`immutable` and constructor-set state** live in the implementation's code, not the\n>    proxy's storage — a frequent source of subtle wrongness.\n> 5. **The upgrade key is the whole security model.** A timelock plus a multisig is the\n>    minimum for anything holding real value.\n\n### 6.2 Access control\n\n**[DURABLE] This is the highest-value section in the document, because access control is\nthe single largest category of on-chain loss (§10.1 → `blockchain-security-testing-and-ops`).**\n\nPatterns: `Ownable` (simple, single point of failure), `Ownable2Step` (**use this instead** —\ntransfer requires acceptance, preventing a typo'd address from permanently orphaning the\ncontract), `AccessControl` (role-based), timelocks (mandatory delay on privileged actions,\ngiving users time to exit), and multisig (Safe is the standard) or full DAO governance.\n\n**The checklist for every privileged function**: is it actually restricted? Is the modifier\npresent on *every* path including the initializer and the upgrade function? Can it be\ncalled before initialization? Is the role transferable, and safely? Is there a timelock on\nanything that can drain or brick the system?\n\n### 6.3 Design principles\n\n**[DURABLE]** **Checks-Effects-Interactions** — validate, then update your state, *then*\nmake external calls. This ordering alone prevents most reentrancy. **Pull over push** for\npayments — let users withdraw rather than pushing funds, so one reverting recipient can't\nblock everyone. **Fail loudly** — revert with custom errors rather than returning false.\n**Minimize privileged surface.** **Emit events for everything** an off-chain system needs\n(§13.4 → `blockchain-security-testing-and-ops`). **Bound every loop.** **Handle the ERC-20 misbehaviours** in §7.1.\n\n---\n\n## §7. Standards\n\n### 7.1 Tokens\n\n| Standard | What |\n|---|---|\n| **ERC-20** | Fungible tokens. ⚠️ See below |\n| **ERC-721** | NFTs. `safeTransferFrom` invokes a receiver hook — **a reentrancy vector** |\n| **ERC-1155** | Multi-token, batch operations |\n| **ERC-4626** | Tokenized vaults. ⚠️ **Inflation\u002Fdonation attacks on the first depositor** are the classic bug — mitigate with virtual shares or a dead-shares seed |\n| **ERC-2612** | `permit` — gasless approvals via signature |\n| **ERC-777** | ⚠️ Hooks caused real reentrancy exploits. **Largely deprecated in practice** |\n\n> **⚠️ GOTCHA — ERC-20 is a standard that many tokens don't follow, and assuming compliance\n> is how integrations break:**\n> - **Non-standard return values** — USDT and others don't return a bool. **Use\n>   OpenZeppelin's `SafeERC20`.**\n> - **Fee-on-transfer tokens** — the amount received ≠ the amount sent. **Measure balance\n>   before and after**, don't trust the argument.\n> - **Rebasing tokens** — balances change without transfers.\n> - **Non-18 decimals** — USDC has 6. Hardcoding 18 is a recurring, expensive bug.\n> - **Blocklists** — USDC\u002FUSDT can freeze addresses, so a transfer can revert forever.\n> - **Approval race** — some tokens require setting the allowance to 0 before changing it.\n> - **Malicious tokens** — if you let anyone list a token, you've let them run arbitrary\n>   code inside your callstack.\n\n### 7.2 The rest\n\n**ERC-165** (interface detection), **EIP-712** (typed structured signing — what makes\nsignature prompts human-readable; ⚠️ **always include a domain separator with `chainId` and\nthe verifying contract, or your signature is replayable across chains and contracts**),\n**ERC-1271** (contract signature validation — necessary for smart accounts),\n**ERC-7201** (namespaced storage layout, §6.1).\n\n### 7.3 Account abstraction\n\n**[VERSIONED] The most consequential UX change in years, and it landed in two pieces.**\n**ERC-4337** implements smart accounts entirely outside the protocol — UserOperations,\na Bundler, an EntryPoint, and Paymasters (which enable sponsored gas and paying fees in\nERC-20). **EIP-7702** (shipped in **Pectra, May 2025**) went further by letting a regular\nEOA temporarily execute as a smart contract, so **existing wallets** gain batching, session\nkeys, sponsored gas, and social recovery **without migrating to a new address**.\n\n**⚠️ EIP-7702 is a live security consideration, not just a feature.** An EOA delegating to\nmalicious code is a new and effective drainer pattern, and wallet and contract code that\nassumes \"`msg.sender` with no code is a plain EOA\" is now making an unsafe assumption.\n\n---\n\n## §8. DeFi Primitives and MEV\n\n### 8.1 The building blocks\n**AMMs** (constant product `x·y=k`; concentrated liquidity; the **impermanent loss** that\nLPs bear), **lending** (over-collateralization, health factors, liquidation incentives),\n**stablecoins** (fiat-backed, over-collateralized crypto-backed, and algorithmic — ⚠️ the\nlast category has an extensive failure history), **derivatives**, and **liquid staking**.\n\n**[DURABLE] Composability is the superpower and the risk.** Contracts calling contracts\ncalling contracts means your protocol's safety depends on dependencies you don't control,\nand a bug three layers down can drain you.\n\n### 8.2 Oracles\n\n**[DURABLE] Oracle manipulation is a top-tier exploit class, and the fix is well known.**\n```\n⚠️ NEVER:   price = reserve1 \u002F reserve0      \u002F\u002F spot price from a DEX pool\n                                              \u002F\u002F — a flash loan moves it in one tx\n✓  INSTEAD: Chainlink \u002F Pyth \u002F RedStone push or pull feeds\n            TWAPs over a meaningful window\n            multiple independent sources with deviation checks\n```\nAnd check the feed's own health: staleness (`updatedAt`), the L2 sequencer uptime feed,\nand sane min\u002Fmax bounds. **⚠️ A stale oracle reading treated as current is itself an\nexploit** — several protocols have lost funds this way without any manipulation at all.\n\n### 8.3 Flash loans\n\nUncollateralized loans that must be repaid in the same transaction. **[DURABLE] Flash loans\nare not the vulnerability — they are the capital amplifier that makes an existing\nvulnerability profitable.** They turn \"an attacker with $100M could do this\" into \"anyone\ncan do this, right now, for a fee.\" **Assume every attacker has unlimited capital for one\ntransaction**, and your threat model becomes correct.\n\n### 8.4 MEV\n\n**[DURABLE]** Maximal Extractable Value — profit from ordering, inserting, or censoring\ntransactions. **Front-running**, **back-running**, **sandwich attacks** (the one that\ndirectly harms ordinary users), **liquidations** and **arbitrage** (arguably beneficial).\n\n**Mitigations for builders**: slippage limits and deadlines on every swap (**a swap with no\nslippage bound is free money for a sandwicher**), commit-reveal schemes, batch auctions,\nprivate mempools\u002Forder flow, and designing so ordering doesn't matter.\n\n**The infrastructure**: proposer-builder separation currently runs through **out-of-protocol\nrelays** (MEV-Boost), which is a real centralization dependency — **which is precisely what\nGlamsterdam's ePBS (§3.2 → `blockchain-protocol-layer`) is intended to bring in-protocol.**\n",{"name":5,"description":7},"develop","ae32736a1aabddabca5d2c96d665aa0ebc7d8700","src\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fcryptocurrency-development\u002Fskills\u002Fblockchain-smart-contract-development",3,"https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey","https:\u002F\u002Fthe-vibey-project.github.io\u002Fvibey\u002F","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project","https:\u002F\u002Fvibewithadam.matthewsteinberger.com","freedom for software engineers","2026-11-15 05:47:42",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add the-vibey-project\u002Fvibey --skill blockchain-smart-contract-development",{"tool":40,"command":41},"bunx","bunx skills add the-vibey-project\u002Fvibey --skill blockchain-smart-contract-development",{"tool":43,"command":44},"pnpm","pnpm dlx skills add the-vibey-project\u002Fvibey --skill blockchain-smart-contract-development","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fcryptocurrency-development\u002Fskills\u002Fblockchain-smart-contract-development\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7AT1FQJAE1FQYAMDTF490Y4","white-paper-writing","Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks \"how should I structure this\" for a long-form document.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fwhite-paper-writing\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7AT16BJRJJKK2MASXRZS76G","prose-technical-mechanics","Use when editing or writing prose at a technical\u002Fmechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-technical-mechanics\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7AT0W9HT0ZZ9Y287NW99MR3","prose-mechanics","Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate\u002FJamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix \"AI-sounding\" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fprose-mechanics\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7AT0KR635JX66X2X6F3E2CP","narrative-structure","Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or \"how should I structure this story\u002Fpitch\u002Fpresentation\" request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fnarrative-structure\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7AT0AKGW09NKKZDYBT8VRDE","legal-brief-writing","Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic\u002Fneurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Flegal-brief-writing\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7AT00VWPS4Q8B5VEMXX9NQT","journal-publishability-criteria","Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs\u002Fpaper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.","https:\u002F\u002Fgithub.com\u002Fthe-vibey-project\u002Fvibey\u002Fblob\u002Fdevelop\u002Fsrc\u002Fvibey_tools\u002Fskills\u002Fplugins\u002Fwriting-craft\u002Fskills\u002Fjournal-publishability-criteria\u002FSKILL.md",[],[]]