[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-aptos-analyze-gas-optimization":3,"mdc-ckwtnq-key":35,"related-repo-aptos-analyze-gas-optimization":3011,"related-org-aptos-analyze-gas-optimization":3106},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":23,"repoUrl":24,"updatedAt":25,"license":26,"forks":27,"topics":28,"repo":30,"sourceUrl":33,"mdContent":34},"analyze-gas-optimization","optimize Aptos Move contracts for gas","Analyze and optimize Aptos Move contracts for gas efficiency, identifying expensive operations and suggesting optimizations. Triggers on: 'optimize gas', 'reduce gas costs', 'gas analysis', 'make contract cheaper', 'gas efficiency', 'analyze gas usage', 'reduce transaction costs'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"aptos","Aptos Labs","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Faptos.png","aptos-labs",[13,17,20],{"name":14,"slug":15,"type":16},"Performance","performance","tag",{"name":18,"slug":19,"type":16},"Blockchain","blockchain",{"name":21,"slug":22,"type":16},"Smart Contracts","smart-contracts",18,"https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-agent-skills","2026-07-12T08:07:14.117466","MIT",8,[29,19],"agent-skills",{"repoUrl":24,"stars":23,"forks":27,"topics":31,"description":32},[29,19],"AI skills for building secure, modern Aptos dApps — Move contracts, TypeScript SDK, and frontend integration for Claude Code, Cursor, and Copilot.","https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-agent-skills\u002Ftree\u002FHEAD\u002Fskills\u002Fmove\u002Fanalyze-gas-optimization","---\nname: analyze-gas-optimization\ndescription:\n  \"Analyze and optimize Aptos Move contracts for gas efficiency, identifying expensive operations and suggesting\n  optimizations. Triggers on: 'optimize gas', 'reduce gas costs', 'gas analysis', 'make contract cheaper', 'gas\n  efficiency', 'analyze gas usage', 'reduce transaction costs'.\"\nlicense: MIT\nmetadata:\n  author: aptos-labs\n  version: \"1.0\"\n  category: move\n  tags: [\"gas\", \"optimization\", \"performance\", \"costs\"]\n  priority: high\n---\n\n# Skill: analyze-gas-optimization\n\nAnalyze and optimize Aptos Move contracts for gas efficiency, identifying expensive operations and suggesting\noptimizations.\n\n## When to Use This Skill\n\n**Trigger phrases:**\n\n- \"optimize gas\", \"reduce gas costs\", \"gas analysis\"\n- \"make contract cheaper\", \"gas efficiency\"\n- \"analyze gas usage\", \"gas optimization\"\n- \"reduce transaction costs\"\n\n**Use cases:**\n\n- Before mainnet deployment\n- When transaction costs are high\n- When optimizing for high-frequency operations\n- When building DeFi protocols with many transactions\n\n## Core Gas Optimization Principles\n\n### 1. Storage Optimization\n\n- Minimize stored data size\n- Use efficient data structures\n- Pack struct fields efficiently\n- Remove unnecessary fields\n\n### 2. Computation Optimization\n\n- Avoid loops over large collections\n- Cache repeated calculations\n- Use bitwise operations when possible\n- Minimize vector operations\n\n### 3. Reference Optimization\n\n- Prefer borrowing over moving when possible\n- Use `&` and `&mut` efficiently\n- Avoid unnecessary copies\n\n## Gas Cost Analysis\n\n### Expensive Operations\n\n#### 1. Global Storage Operations\n\n```move\n\u002F\u002F EXPENSIVE: Writing to global storage\nmove_to(account, large_struct);\n\n\u002F\u002F EXPENSIVE: Reading and writing\nlet data = borrow_global_mut\u003CLargeData>(addr);\n\n\u002F\u002F EXPENSIVE: Checking existence\nif (exists\u003CResource>(addr)) { ... }\n```\n\n#### 2. Vector Operations\n\n```move\n\u002F\u002F EXPENSIVE: Growing vectors dynamically\nvector::push_back(&mut vec, item); \u002F\u002F O(n) worst case\n\n\u002F\u002F EXPENSIVE: Searching vectors\nvector::contains(&vec, &item); \u002F\u002F O(n)\n\n\u002F\u002F EXPENSIVE: Removing from middle\nvector::remove(&mut vec, index); \u002F\u002F O(n)\n```\n\n#### 3. String Operations\n\n```move\n\u002F\u002F EXPENSIVE: String concatenation\nstring::append(&mut s1, s2);\n\n\u002F\u002F EXPENSIVE: UTF8 validation\nstring::utf8(bytes);\n```\n\n### Optimization Patterns\n\n#### 1. Batch Operations\n\n```move\n\u002F\u002F BAD: Multiple storage accesses\npublic fun update_values(account: &signer, updates: vector\u003CUpdate>) {\n    let i = 0;\n    while (i \u003C vector::length(&updates)) {\n        let update = vector::borrow(&updates, i);\n        let data = borrow_global_mut\u003CData>(update.address);\n        data.value = update.value;\n        i = i + 1;\n    }\n}\n\n\u002F\u002F GOOD: Single storage access with batch update\npublic fun batch_update(account: &signer, updates: vector\u003CUpdate>) {\n    let data = borrow_global_mut\u003CData>(signer::address_of(account));\n    let i = 0;\n    while (i \u003C vector::length(&updates)) {\n        let update = vector::borrow(&updates, i);\n        \u002F\u002F Update in memory\n        update_memory_data(data, update);\n        i = i + 1;\n    }\n}\n```\n\n#### 2. Storage Packing\n\n```move\n\u002F\u002F BAD: Wasteful storage\nstruct UserData has key {\n    active: bool,      \u002F\u002F 1 byte used, 7 wasted\n    level: u8,         \u002F\u002F 1 byte used, 7 wasted\n    score: u64,        \u002F\u002F 8 bytes\n    timestamp: u64,    \u002F\u002F 8 bytes\n    \u002F\u002F Total: 32 bytes (50% wasted)\n}\n\n\u002F\u002F GOOD: Packed storage\nstruct UserData has key {\n    \u002F\u002F Pack small fields together\n    flags: u8,         \u002F\u002F Bits: [active, reserved...]\n    level: u8,\n    reserved: u16,     \u002F\u002F Future use\n    score: u64,\n    timestamp: u64,\n    \u002F\u002F Total: 20 bytes (37.5% saved)\n}\n```\n\n#### 3. Lazy Evaluation\n\n```move\n\u002F\u002F BAD: Always compute expensive value\nstruct Pool has key {\n    total_shares: u64,\n    total_assets: u64,\n    \u002F\u002F Computed on every update\n    share_price: u64,\n}\n\n\u002F\u002F GOOD: Compute only when needed\nstruct Pool has key {\n    total_shares: u64,\n    total_assets: u64,\n    \u002F\u002F Don't store computed values\n}\n\npublic fun get_share_price(pool_addr: address): u64 {\n    let pool = borrow_global\u003CPool>(pool_addr);\n    if (pool.total_shares == 0) {\n        INITIAL_SHARE_PRICE\n    } else {\n        pool.total_assets * PRECISION \u002F pool.total_shares\n    }\n}\n```\n\n#### 4. Event Optimization\n\n```move\n\u002F\u002F BAD: Large event data\nstruct TradeEvent has drop, store {\n    pool: Object\u003CPool>,\n    trader: address,\n    token_in: Object\u003CToken>,\n    token_out: Object\u003CToken>,\n    amount_in: u64,\n    amount_out: u64,\n    fees: u64,\n    timestamp: u64,\n    metadata: vector\u003Cu8>, \u002F\u002F Large metadata\n}\n\n\u002F\u002F GOOD: Minimal event data\nstruct TradeEvent has drop, store {\n    pool_id: u64,        \u002F\u002F Use ID instead of Object\n    trader: address,\n    amounts: u128,       \u002F\u002F Pack amount_in and amount_out\n    fees: u64,\n    \u002F\u002F Compute other data from state\n}\n```\n\n#### 5. Collection Optimization\n\n```move\n\u002F\u002F BAD: Linear search\npublic fun find_item(items: &vector\u003CItem>, id: u64): Option\u003CItem> {\n    let i = 0;\n    while (i \u003C vector::length(items)) {\n        let item = vector::borrow(items, i);\n        if (item.id == id) {\n            return option::some(*item)\n        };\n        i = i + 1;\n    }\n    option::none()\n}\n\n\u002F\u002F GOOD: Use Table for O(1) lookup\nstruct Storage has key {\n    items: Table\u003Cu64, Item>,\n}\n\npublic fun find_item(storage: &Storage, id: u64): Option\u003CItem> {\n    if (table::contains(&storage.items, id)) {\n        option::some(*table::borrow(&storage.items, id))\n    } else {\n        option::none()\n    }\n}\n```\n\n## Gas Measurement\n\n### 1. Transaction Simulation\n\n```bash\n# Simulate to get gas estimate\naptos move run-function \\\n    --function-id 0x1::module::function \\\n    --args ... \\\n    --simulate\n\n# Output includes:\n# - gas_unit_price\n# - max_gas_amount\n# - gas_used\n```\n\n### 2. Gas Profiling\n\n```move\n#[test]\npublic fun test_gas_usage() {\n    \u002F\u002F Measure gas for operation\n    let gas_before = gas::remaining_gas();\n    expensive_operation();\n    let gas_used = gas_before - gas::remaining_gas();\n\n    \u002F\u002F Assert reasonable gas usage\n    assert!(gas_used \u003C MAX_ACCEPTABLE_GAS, E_TOO_EXPENSIVE);\n}\n```\n\n## Optimization Checklist\n\n### Storage Checklist\n\n- [ ] Pack struct fields to minimize size\n- [ ] Use appropriate integer sizes (u8, u16, u32, u64)\n- [ ] Remove unnecessary fields\n- [ ] Consider off-chain storage for large data\n- [ ] Use events instead of storage for logs\n\n### Computation Checklist\n\n- [ ] Cache repeated calculations\n- [ ] Minimize loops over collections\n- [ ] Use early returns to skip unnecessary work\n- [ ] Batch similar operations\n- [ ] Avoid redundant checks\n\n### Collection Checklist\n\n- [ ] Use Table\u002FTableWithLength for key-value lookups\n- [ ] Use SmartTable for large collections\n- [ ] Limit vector sizes\n- [ ] Consider pagination for large results\n- [ ] Use appropriate data structures\n\n### Best Practices\n\n- [ ] Profile before and after optimization\n- [ ] Test gas usage in unit tests\n- [ ] Document gas costs for public functions\n- [ ] Consider gas costs in contract design\n- [ ] Monitor mainnet gas usage\n\n## Common Gas Optimizations\n\n### 1. Replace Vectors with Tables\n\n```move\n\u002F\u002F Before: O(n) search\nstruct Registry has key {\n    users: vector\u003CUser>,\n}\n\n\u002F\u002F After: O(1) lookup\nstruct Registry has key {\n    users: Table\u003Caddress, User>,\n    user_list: vector\u003Caddress>, \u002F\u002F If iteration needed\n}\n```\n\n### 2. Minimize Storage Reads\n\n```move\n\u002F\u002F Before: Multiple reads\npublic fun transfer(from: &signer, to: address, amount: u64) {\n    assert!(get_balance(signer::address_of(from)) >= amount, E_INSUFFICIENT);\n    let from_balance = borrow_global_mut\u003CBalance>(signer::address_of(from));\n    let to_balance = borrow_global_mut\u003CBalance>(to);\n    \u002F\u002F ...\n}\n\n\u002F\u002F After: Single read with validation\npublic fun transfer(from: &signer, to: address, amount: u64) {\n    let from_addr = signer::address_of(from);\n    let from_balance = borrow_global_mut\u003CBalance>(from_addr);\n    assert!(from_balance.value >= amount, E_INSUFFICIENT);\n    \u002F\u002F ... rest of logic\n}\n```\n\n### 3. Use Bitwise Flags\n\n```move\n\u002F\u002F Before: Multiple bool fields (8 bytes each)\nstruct Settings has copy, drop, store {\n    is_active: bool,\n    is_paused: bool,\n    is_initialized: bool,\n    allows_deposits: bool,\n}\n\n\u002F\u002F After: Single u8 (1 byte)\nstruct Settings has copy, drop, store {\n    flags: u8, \u002F\u002F Bit 0: active, 1: paused, 2: initialized, 3: deposits\n}\n\nconst FLAG_ACTIVE: u8 = 1;        \u002F\u002F 0b00000001\nconst FLAG_PAUSED: u8 = 2;        \u002F\u002F 0b00000010\nconst FLAG_INITIALIZED: u8 = 4;   \u002F\u002F 0b00000100\nconst FLAG_DEPOSITS: u8 = 8;      \u002F\u002F 0b00001000\n\npublic fun is_active(settings: &Settings): bool {\n    (settings.flags & FLAG_ACTIVE) != 0\n}\n```\n\n## Gas Optimization Report Template\n\n```markdown\n# Gas Optimization Report\n\n## Summary\n\n- Current average gas: X units\n- Optimized average gas: Y units\n- Savings: Z% reduction\n\n## Optimizations Applied\n\n### 1. Storage Optimization\n\n- Packed struct fields (saved X bytes)\n- Replaced vectors with tables (O(n) → O(1))\n- Removed redundant fields\n\n### 2. Computation Optimization\n\n- Cached price calculations (saved X operations)\n- Batched updates (N calls → 1 call)\n- Early returns in validation\n\n### 3. Event Optimization\n\n- Reduced event size from X to Y bytes\n- Removed redundant event fields\n\n## Measurements\n\n| Function | Before | After  | Savings |\n| -------- | ------ | ------ | ------- |\n| mint     | 50,000 | 35,000 | 30%     |\n| transfer | 30,000 | 25,000 | 17%     |\n| swap     | 80,000 | 60,000 | 25%     |\n\n## Recommendations\n\n1. Consider further optimizations for high-frequency functions\n2. Monitor mainnet usage patterns\n3. Set up gas usage alerts\n```\n\n## Integration Notes\n\n- Works with `security-audit` to ensure optimizations don't compromise security\n- Use with `generate-tests` to verify optimizations maintain correctness\n- Apply before `deploy-contracts` for mainnet deployments\n- Reference `STORAGE_OPTIMIZATION.md` for detailed patterns\n\n## NEVER Rules\n\n- ❌ NEVER optimize away security checks (access control, input validation)\n- ❌ NEVER deploy optimized code without re-testing\n- ❌ NEVER read `.env` or `~\u002F.aptos\u002Fconfig.yaml` during gas analysis (contain private keys)\n\n## References\n\n- Aptos Gas Schedule: https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-core\u002Fblob\u002Fmain\u002Faptos-move\u002Faptos-gas-schedule\n- Move VM Gas Metering: https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-core\u002Ftree\u002Fmain\u002Faptos-move\u002Faptos-vm\n- Gas Optimization Patterns: Check daily-move repository for real examples\n",{"data":36,"body":45},{"name":4,"description":6,"license":26,"metadata":37},{"author":11,"version":38,"category":39,"tags":40,"priority":44},"1.0","move",[41,42,15,43],"gas","optimization","costs","high",{"type":46,"children":47},"root",[48,57,63,70,79,104,112,135,141,148,171,177,200,206,241,247,253,260,343,349,418,424,470,476,482,671,677,832,838,1021,1027,1195,1201,1400,1406,1412,1536,1542,1627,1633,1639,1692,1698,1747,1753,1802,1808,1857,1863,1869,1952,1958,2081,2087,2255,2261,2866,2872,2927,2933,2967,2973,3005],{"type":49,"tag":50,"props":51,"children":53},"element","h1",{"id":52},"skill-analyze-gas-optimization",[54],{"type":55,"value":56},"text","Skill: analyze-gas-optimization",{"type":49,"tag":58,"props":59,"children":60},"p",{},[61],{"type":55,"value":62},"Analyze and optimize Aptos Move contracts for gas efficiency, identifying expensive operations and suggesting\noptimizations.",{"type":49,"tag":64,"props":65,"children":67},"h2",{"id":66},"when-to-use-this-skill",[68],{"type":55,"value":69},"When to Use This Skill",{"type":49,"tag":58,"props":71,"children":72},{},[73],{"type":49,"tag":74,"props":75,"children":76},"strong",{},[77],{"type":55,"value":78},"Trigger phrases:",{"type":49,"tag":80,"props":81,"children":82},"ul",{},[83,89,94,99],{"type":49,"tag":84,"props":85,"children":86},"li",{},[87],{"type":55,"value":88},"\"optimize gas\", \"reduce gas costs\", \"gas analysis\"",{"type":49,"tag":84,"props":90,"children":91},{},[92],{"type":55,"value":93},"\"make contract cheaper\", \"gas efficiency\"",{"type":49,"tag":84,"props":95,"children":96},{},[97],{"type":55,"value":98},"\"analyze gas usage\", \"gas optimization\"",{"type":49,"tag":84,"props":100,"children":101},{},[102],{"type":55,"value":103},"\"reduce transaction costs\"",{"type":49,"tag":58,"props":105,"children":106},{},[107],{"type":49,"tag":74,"props":108,"children":109},{},[110],{"type":55,"value":111},"Use cases:",{"type":49,"tag":80,"props":113,"children":114},{},[115,120,125,130],{"type":49,"tag":84,"props":116,"children":117},{},[118],{"type":55,"value":119},"Before mainnet deployment",{"type":49,"tag":84,"props":121,"children":122},{},[123],{"type":55,"value":124},"When transaction costs are high",{"type":49,"tag":84,"props":126,"children":127},{},[128],{"type":55,"value":129},"When optimizing for high-frequency operations",{"type":49,"tag":84,"props":131,"children":132},{},[133],{"type":55,"value":134},"When building DeFi protocols with many transactions",{"type":49,"tag":64,"props":136,"children":138},{"id":137},"core-gas-optimization-principles",[139],{"type":55,"value":140},"Core Gas Optimization Principles",{"type":49,"tag":142,"props":143,"children":145},"h3",{"id":144},"_1-storage-optimization",[146],{"type":55,"value":147},"1. Storage Optimization",{"type":49,"tag":80,"props":149,"children":150},{},[151,156,161,166],{"type":49,"tag":84,"props":152,"children":153},{},[154],{"type":55,"value":155},"Minimize stored data size",{"type":49,"tag":84,"props":157,"children":158},{},[159],{"type":55,"value":160},"Use efficient data structures",{"type":49,"tag":84,"props":162,"children":163},{},[164],{"type":55,"value":165},"Pack struct fields efficiently",{"type":49,"tag":84,"props":167,"children":168},{},[169],{"type":55,"value":170},"Remove unnecessary fields",{"type":49,"tag":142,"props":172,"children":174},{"id":173},"_2-computation-optimization",[175],{"type":55,"value":176},"2. Computation Optimization",{"type":49,"tag":80,"props":178,"children":179},{},[180,185,190,195],{"type":49,"tag":84,"props":181,"children":182},{},[183],{"type":55,"value":184},"Avoid loops over large collections",{"type":49,"tag":84,"props":186,"children":187},{},[188],{"type":55,"value":189},"Cache repeated calculations",{"type":49,"tag":84,"props":191,"children":192},{},[193],{"type":55,"value":194},"Use bitwise operations when possible",{"type":49,"tag":84,"props":196,"children":197},{},[198],{"type":55,"value":199},"Minimize vector operations",{"type":49,"tag":142,"props":201,"children":203},{"id":202},"_3-reference-optimization",[204],{"type":55,"value":205},"3. Reference Optimization",{"type":49,"tag":80,"props":207,"children":208},{},[209,214,236],{"type":49,"tag":84,"props":210,"children":211},{},[212],{"type":55,"value":213},"Prefer borrowing over moving when possible",{"type":49,"tag":84,"props":215,"children":216},{},[217,219,226,228,234],{"type":55,"value":218},"Use ",{"type":49,"tag":220,"props":221,"children":223},"code",{"className":222},[],[224],{"type":55,"value":225},"&",{"type":55,"value":227}," and ",{"type":49,"tag":220,"props":229,"children":231},{"className":230},[],[232],{"type":55,"value":233},"&mut",{"type":55,"value":235}," efficiently",{"type":49,"tag":84,"props":237,"children":238},{},[239],{"type":55,"value":240},"Avoid unnecessary copies",{"type":49,"tag":64,"props":242,"children":244},{"id":243},"gas-cost-analysis",[245],{"type":55,"value":246},"Gas Cost Analysis",{"type":49,"tag":142,"props":248,"children":250},{"id":249},"expensive-operations",[251],{"type":55,"value":252},"Expensive Operations",{"type":49,"tag":254,"props":255,"children":257},"h4",{"id":256},"_1-global-storage-operations",[258],{"type":55,"value":259},"1. Global Storage Operations",{"type":49,"tag":261,"props":262,"children":266},"pre",{"className":263,"code":264,"language":39,"meta":265,"style":265},"language-move shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F EXPENSIVE: Writing to global storage\nmove_to(account, large_struct);\n\n\u002F\u002F EXPENSIVE: Reading and writing\nlet data = borrow_global_mut\u003CLargeData>(addr);\n\n\u002F\u002F EXPENSIVE: Checking existence\nif (exists\u003CResource>(addr)) { ... }\n","",[267],{"type":49,"tag":220,"props":268,"children":269},{"__ignoreMap":265},[270,281,290,300,309,318,326,335],{"type":49,"tag":271,"props":272,"children":275},"span",{"class":273,"line":274},"line",1,[276],{"type":49,"tag":271,"props":277,"children":278},{},[279],{"type":55,"value":280},"\u002F\u002F EXPENSIVE: Writing to global storage\n",{"type":49,"tag":271,"props":282,"children":284},{"class":273,"line":283},2,[285],{"type":49,"tag":271,"props":286,"children":287},{},[288],{"type":55,"value":289},"move_to(account, large_struct);\n",{"type":49,"tag":271,"props":291,"children":293},{"class":273,"line":292},3,[294],{"type":49,"tag":271,"props":295,"children":297},{"emptyLinePlaceholder":296},true,[298],{"type":55,"value":299},"\n",{"type":49,"tag":271,"props":301,"children":303},{"class":273,"line":302},4,[304],{"type":49,"tag":271,"props":305,"children":306},{},[307],{"type":55,"value":308},"\u002F\u002F EXPENSIVE: Reading and writing\n",{"type":49,"tag":271,"props":310,"children":312},{"class":273,"line":311},5,[313],{"type":49,"tag":271,"props":314,"children":315},{},[316],{"type":55,"value":317},"let data = borrow_global_mut\u003CLargeData>(addr);\n",{"type":49,"tag":271,"props":319,"children":321},{"class":273,"line":320},6,[322],{"type":49,"tag":271,"props":323,"children":324},{"emptyLinePlaceholder":296},[325],{"type":55,"value":299},{"type":49,"tag":271,"props":327,"children":329},{"class":273,"line":328},7,[330],{"type":49,"tag":271,"props":331,"children":332},{},[333],{"type":55,"value":334},"\u002F\u002F EXPENSIVE: Checking existence\n",{"type":49,"tag":271,"props":336,"children":337},{"class":273,"line":27},[338],{"type":49,"tag":271,"props":339,"children":340},{},[341],{"type":55,"value":342},"if (exists\u003CResource>(addr)) { ... }\n",{"type":49,"tag":254,"props":344,"children":346},{"id":345},"_2-vector-operations",[347],{"type":55,"value":348},"2. Vector Operations",{"type":49,"tag":261,"props":350,"children":352},{"className":263,"code":351,"language":39,"meta":265,"style":265},"\u002F\u002F EXPENSIVE: Growing vectors dynamically\nvector::push_back(&mut vec, item); \u002F\u002F O(n) worst case\n\n\u002F\u002F EXPENSIVE: Searching vectors\nvector::contains(&vec, &item); \u002F\u002F O(n)\n\n\u002F\u002F EXPENSIVE: Removing from middle\nvector::remove(&mut vec, index); \u002F\u002F O(n)\n",[353],{"type":49,"tag":220,"props":354,"children":355},{"__ignoreMap":265},[356,364,372,379,387,395,402,410],{"type":49,"tag":271,"props":357,"children":358},{"class":273,"line":274},[359],{"type":49,"tag":271,"props":360,"children":361},{},[362],{"type":55,"value":363},"\u002F\u002F EXPENSIVE: Growing vectors dynamically\n",{"type":49,"tag":271,"props":365,"children":366},{"class":273,"line":283},[367],{"type":49,"tag":271,"props":368,"children":369},{},[370],{"type":55,"value":371},"vector::push_back(&mut vec, item); \u002F\u002F O(n) worst case\n",{"type":49,"tag":271,"props":373,"children":374},{"class":273,"line":292},[375],{"type":49,"tag":271,"props":376,"children":377},{"emptyLinePlaceholder":296},[378],{"type":55,"value":299},{"type":49,"tag":271,"props":380,"children":381},{"class":273,"line":302},[382],{"type":49,"tag":271,"props":383,"children":384},{},[385],{"type":55,"value":386},"\u002F\u002F EXPENSIVE: Searching vectors\n",{"type":49,"tag":271,"props":388,"children":389},{"class":273,"line":311},[390],{"type":49,"tag":271,"props":391,"children":392},{},[393],{"type":55,"value":394},"vector::contains(&vec, &item); \u002F\u002F O(n)\n",{"type":49,"tag":271,"props":396,"children":397},{"class":273,"line":320},[398],{"type":49,"tag":271,"props":399,"children":400},{"emptyLinePlaceholder":296},[401],{"type":55,"value":299},{"type":49,"tag":271,"props":403,"children":404},{"class":273,"line":328},[405],{"type":49,"tag":271,"props":406,"children":407},{},[408],{"type":55,"value":409},"\u002F\u002F EXPENSIVE: Removing from middle\n",{"type":49,"tag":271,"props":411,"children":412},{"class":273,"line":27},[413],{"type":49,"tag":271,"props":414,"children":415},{},[416],{"type":55,"value":417},"vector::remove(&mut vec, index); \u002F\u002F O(n)\n",{"type":49,"tag":254,"props":419,"children":421},{"id":420},"_3-string-operations",[422],{"type":55,"value":423},"3. String Operations",{"type":49,"tag":261,"props":425,"children":427},{"className":263,"code":426,"language":39,"meta":265,"style":265},"\u002F\u002F EXPENSIVE: String concatenation\nstring::append(&mut s1, s2);\n\n\u002F\u002F EXPENSIVE: UTF8 validation\nstring::utf8(bytes);\n",[428],{"type":49,"tag":220,"props":429,"children":430},{"__ignoreMap":265},[431,439,447,454,462],{"type":49,"tag":271,"props":432,"children":433},{"class":273,"line":274},[434],{"type":49,"tag":271,"props":435,"children":436},{},[437],{"type":55,"value":438},"\u002F\u002F EXPENSIVE: String concatenation\n",{"type":49,"tag":271,"props":440,"children":441},{"class":273,"line":283},[442],{"type":49,"tag":271,"props":443,"children":444},{},[445],{"type":55,"value":446},"string::append(&mut s1, s2);\n",{"type":49,"tag":271,"props":448,"children":449},{"class":273,"line":292},[450],{"type":49,"tag":271,"props":451,"children":452},{"emptyLinePlaceholder":296},[453],{"type":55,"value":299},{"type":49,"tag":271,"props":455,"children":456},{"class":273,"line":302},[457],{"type":49,"tag":271,"props":458,"children":459},{},[460],{"type":55,"value":461},"\u002F\u002F EXPENSIVE: UTF8 validation\n",{"type":49,"tag":271,"props":463,"children":464},{"class":273,"line":311},[465],{"type":49,"tag":271,"props":466,"children":467},{},[468],{"type":55,"value":469},"string::utf8(bytes);\n",{"type":49,"tag":142,"props":471,"children":473},{"id":472},"optimization-patterns",[474],{"type":55,"value":475},"Optimization Patterns",{"type":49,"tag":254,"props":477,"children":479},{"id":478},"_1-batch-operations",[480],{"type":55,"value":481},"1. Batch Operations",{"type":49,"tag":261,"props":483,"children":485},{"className":263,"code":484,"language":39,"meta":265,"style":265},"\u002F\u002F BAD: Multiple storage accesses\npublic fun update_values(account: &signer, updates: vector\u003CUpdate>) {\n    let i = 0;\n    while (i \u003C vector::length(&updates)) {\n        let update = vector::borrow(&updates, i);\n        let data = borrow_global_mut\u003CData>(update.address);\n        data.value = update.value;\n        i = i + 1;\n    }\n}\n\n\u002F\u002F GOOD: Single storage access with batch update\npublic fun batch_update(account: &signer, updates: vector\u003CUpdate>) {\n    let data = borrow_global_mut\u003CData>(signer::address_of(account));\n    let i = 0;\n    while (i \u003C vector::length(&updates)) {\n        let update = vector::borrow(&updates, i);\n        \u002F\u002F Update in memory\n        update_memory_data(data, update);\n        i = i + 1;\n    }\n}\n",[486],{"type":49,"tag":220,"props":487,"children":488},{"__ignoreMap":265},[489,497,505,513,521,529,537,545,553,562,571,579,588,597,606,614,622,630,638,647,655,663],{"type":49,"tag":271,"props":490,"children":491},{"class":273,"line":274},[492],{"type":49,"tag":271,"props":493,"children":494},{},[495],{"type":55,"value":496},"\u002F\u002F BAD: Multiple storage accesses\n",{"type":49,"tag":271,"props":498,"children":499},{"class":273,"line":283},[500],{"type":49,"tag":271,"props":501,"children":502},{},[503],{"type":55,"value":504},"public fun update_values(account: &signer, updates: vector\u003CUpdate>) {\n",{"type":49,"tag":271,"props":506,"children":507},{"class":273,"line":292},[508],{"type":49,"tag":271,"props":509,"children":510},{},[511],{"type":55,"value":512},"    let i = 0;\n",{"type":49,"tag":271,"props":514,"children":515},{"class":273,"line":302},[516],{"type":49,"tag":271,"props":517,"children":518},{},[519],{"type":55,"value":520},"    while (i \u003C vector::length(&updates)) {\n",{"type":49,"tag":271,"props":522,"children":523},{"class":273,"line":311},[524],{"type":49,"tag":271,"props":525,"children":526},{},[527],{"type":55,"value":528},"        let update = vector::borrow(&updates, i);\n",{"type":49,"tag":271,"props":530,"children":531},{"class":273,"line":320},[532],{"type":49,"tag":271,"props":533,"children":534},{},[535],{"type":55,"value":536},"        let data = borrow_global_mut\u003CData>(update.address);\n",{"type":49,"tag":271,"props":538,"children":539},{"class":273,"line":328},[540],{"type":49,"tag":271,"props":541,"children":542},{},[543],{"type":55,"value":544},"        data.value = update.value;\n",{"type":49,"tag":271,"props":546,"children":547},{"class":273,"line":27},[548],{"type":49,"tag":271,"props":549,"children":550},{},[551],{"type":55,"value":552},"        i = i + 1;\n",{"type":49,"tag":271,"props":554,"children":556},{"class":273,"line":555},9,[557],{"type":49,"tag":271,"props":558,"children":559},{},[560],{"type":55,"value":561},"    }\n",{"type":49,"tag":271,"props":563,"children":565},{"class":273,"line":564},10,[566],{"type":49,"tag":271,"props":567,"children":568},{},[569],{"type":55,"value":570},"}\n",{"type":49,"tag":271,"props":572,"children":574},{"class":273,"line":573},11,[575],{"type":49,"tag":271,"props":576,"children":577},{"emptyLinePlaceholder":296},[578],{"type":55,"value":299},{"type":49,"tag":271,"props":580,"children":582},{"class":273,"line":581},12,[583],{"type":49,"tag":271,"props":584,"children":585},{},[586],{"type":55,"value":587},"\u002F\u002F GOOD: Single storage access with batch update\n",{"type":49,"tag":271,"props":589,"children":591},{"class":273,"line":590},13,[592],{"type":49,"tag":271,"props":593,"children":594},{},[595],{"type":55,"value":596},"public fun batch_update(account: &signer, updates: vector\u003CUpdate>) {\n",{"type":49,"tag":271,"props":598,"children":600},{"class":273,"line":599},14,[601],{"type":49,"tag":271,"props":602,"children":603},{},[604],{"type":55,"value":605},"    let data = borrow_global_mut\u003CData>(signer::address_of(account));\n",{"type":49,"tag":271,"props":607,"children":609},{"class":273,"line":608},15,[610],{"type":49,"tag":271,"props":611,"children":612},{},[613],{"type":55,"value":512},{"type":49,"tag":271,"props":615,"children":617},{"class":273,"line":616},16,[618],{"type":49,"tag":271,"props":619,"children":620},{},[621],{"type":55,"value":520},{"type":49,"tag":271,"props":623,"children":625},{"class":273,"line":624},17,[626],{"type":49,"tag":271,"props":627,"children":628},{},[629],{"type":55,"value":528},{"type":49,"tag":271,"props":631,"children":632},{"class":273,"line":23},[633],{"type":49,"tag":271,"props":634,"children":635},{},[636],{"type":55,"value":637},"        \u002F\u002F Update in memory\n",{"type":49,"tag":271,"props":639,"children":641},{"class":273,"line":640},19,[642],{"type":49,"tag":271,"props":643,"children":644},{},[645],{"type":55,"value":646},"        update_memory_data(data, update);\n",{"type":49,"tag":271,"props":648,"children":650},{"class":273,"line":649},20,[651],{"type":49,"tag":271,"props":652,"children":653},{},[654],{"type":55,"value":552},{"type":49,"tag":271,"props":656,"children":658},{"class":273,"line":657},21,[659],{"type":49,"tag":271,"props":660,"children":661},{},[662],{"type":55,"value":561},{"type":49,"tag":271,"props":664,"children":666},{"class":273,"line":665},22,[667],{"type":49,"tag":271,"props":668,"children":669},{},[670],{"type":55,"value":570},{"type":49,"tag":254,"props":672,"children":674},{"id":673},"_2-storage-packing",[675],{"type":55,"value":676},"2. Storage Packing",{"type":49,"tag":261,"props":678,"children":680},{"className":263,"code":679,"language":39,"meta":265,"style":265},"\u002F\u002F BAD: Wasteful storage\nstruct UserData has key {\n    active: bool,      \u002F\u002F 1 byte used, 7 wasted\n    level: u8,         \u002F\u002F 1 byte used, 7 wasted\n    score: u64,        \u002F\u002F 8 bytes\n    timestamp: u64,    \u002F\u002F 8 bytes\n    \u002F\u002F Total: 32 bytes (50% wasted)\n}\n\n\u002F\u002F GOOD: Packed storage\nstruct UserData has key {\n    \u002F\u002F Pack small fields together\n    flags: u8,         \u002F\u002F Bits: [active, reserved...]\n    level: u8,\n    reserved: u16,     \u002F\u002F Future use\n    score: u64,\n    timestamp: u64,\n    \u002F\u002F Total: 20 bytes (37.5% saved)\n}\n",[681],{"type":49,"tag":220,"props":682,"children":683},{"__ignoreMap":265},[684,692,700,708,716,724,732,740,747,754,762,769,777,785,793,801,809,817,825],{"type":49,"tag":271,"props":685,"children":686},{"class":273,"line":274},[687],{"type":49,"tag":271,"props":688,"children":689},{},[690],{"type":55,"value":691},"\u002F\u002F BAD: Wasteful storage\n",{"type":49,"tag":271,"props":693,"children":694},{"class":273,"line":283},[695],{"type":49,"tag":271,"props":696,"children":697},{},[698],{"type":55,"value":699},"struct UserData has key {\n",{"type":49,"tag":271,"props":701,"children":702},{"class":273,"line":292},[703],{"type":49,"tag":271,"props":704,"children":705},{},[706],{"type":55,"value":707},"    active: bool,      \u002F\u002F 1 byte used, 7 wasted\n",{"type":49,"tag":271,"props":709,"children":710},{"class":273,"line":302},[711],{"type":49,"tag":271,"props":712,"children":713},{},[714],{"type":55,"value":715},"    level: u8,         \u002F\u002F 1 byte used, 7 wasted\n",{"type":49,"tag":271,"props":717,"children":718},{"class":273,"line":311},[719],{"type":49,"tag":271,"props":720,"children":721},{},[722],{"type":55,"value":723},"    score: u64,        \u002F\u002F 8 bytes\n",{"type":49,"tag":271,"props":725,"children":726},{"class":273,"line":320},[727],{"type":49,"tag":271,"props":728,"children":729},{},[730],{"type":55,"value":731},"    timestamp: u64,    \u002F\u002F 8 bytes\n",{"type":49,"tag":271,"props":733,"children":734},{"class":273,"line":328},[735],{"type":49,"tag":271,"props":736,"children":737},{},[738],{"type":55,"value":739},"    \u002F\u002F Total: 32 bytes (50% wasted)\n",{"type":49,"tag":271,"props":741,"children":742},{"class":273,"line":27},[743],{"type":49,"tag":271,"props":744,"children":745},{},[746],{"type":55,"value":570},{"type":49,"tag":271,"props":748,"children":749},{"class":273,"line":555},[750],{"type":49,"tag":271,"props":751,"children":752},{"emptyLinePlaceholder":296},[753],{"type":55,"value":299},{"type":49,"tag":271,"props":755,"children":756},{"class":273,"line":564},[757],{"type":49,"tag":271,"props":758,"children":759},{},[760],{"type":55,"value":761},"\u002F\u002F GOOD: Packed storage\n",{"type":49,"tag":271,"props":763,"children":764},{"class":273,"line":573},[765],{"type":49,"tag":271,"props":766,"children":767},{},[768],{"type":55,"value":699},{"type":49,"tag":271,"props":770,"children":771},{"class":273,"line":581},[772],{"type":49,"tag":271,"props":773,"children":774},{},[775],{"type":55,"value":776},"    \u002F\u002F Pack small fields together\n",{"type":49,"tag":271,"props":778,"children":779},{"class":273,"line":590},[780],{"type":49,"tag":271,"props":781,"children":782},{},[783],{"type":55,"value":784},"    flags: u8,         \u002F\u002F Bits: [active, reserved...]\n",{"type":49,"tag":271,"props":786,"children":787},{"class":273,"line":599},[788],{"type":49,"tag":271,"props":789,"children":790},{},[791],{"type":55,"value":792},"    level: u8,\n",{"type":49,"tag":271,"props":794,"children":795},{"class":273,"line":608},[796],{"type":49,"tag":271,"props":797,"children":798},{},[799],{"type":55,"value":800},"    reserved: u16,     \u002F\u002F Future use\n",{"type":49,"tag":271,"props":802,"children":803},{"class":273,"line":616},[804],{"type":49,"tag":271,"props":805,"children":806},{},[807],{"type":55,"value":808},"    score: u64,\n",{"type":49,"tag":271,"props":810,"children":811},{"class":273,"line":624},[812],{"type":49,"tag":271,"props":813,"children":814},{},[815],{"type":55,"value":816},"    timestamp: u64,\n",{"type":49,"tag":271,"props":818,"children":819},{"class":273,"line":23},[820],{"type":49,"tag":271,"props":821,"children":822},{},[823],{"type":55,"value":824},"    \u002F\u002F Total: 20 bytes (37.5% saved)\n",{"type":49,"tag":271,"props":826,"children":827},{"class":273,"line":640},[828],{"type":49,"tag":271,"props":829,"children":830},{},[831],{"type":55,"value":570},{"type":49,"tag":254,"props":833,"children":835},{"id":834},"_3-lazy-evaluation",[836],{"type":55,"value":837},"3. Lazy Evaluation",{"type":49,"tag":261,"props":839,"children":841},{"className":263,"code":840,"language":39,"meta":265,"style":265},"\u002F\u002F BAD: Always compute expensive value\nstruct Pool has key {\n    total_shares: u64,\n    total_assets: u64,\n    \u002F\u002F Computed on every update\n    share_price: u64,\n}\n\n\u002F\u002F GOOD: Compute only when needed\nstruct Pool has key {\n    total_shares: u64,\n    total_assets: u64,\n    \u002F\u002F Don't store computed values\n}\n\npublic fun get_share_price(pool_addr: address): u64 {\n    let pool = borrow_global\u003CPool>(pool_addr);\n    if (pool.total_shares == 0) {\n        INITIAL_SHARE_PRICE\n    } else {\n        pool.total_assets * PRECISION \u002F pool.total_shares\n    }\n}\n",[842],{"type":49,"tag":220,"props":843,"children":844},{"__ignoreMap":265},[845,853,861,869,877,885,893,900,907,915,922,929,936,944,951,958,966,974,982,990,998,1006,1013],{"type":49,"tag":271,"props":846,"children":847},{"class":273,"line":274},[848],{"type":49,"tag":271,"props":849,"children":850},{},[851],{"type":55,"value":852},"\u002F\u002F BAD: Always compute expensive value\n",{"type":49,"tag":271,"props":854,"children":855},{"class":273,"line":283},[856],{"type":49,"tag":271,"props":857,"children":858},{},[859],{"type":55,"value":860},"struct Pool has key {\n",{"type":49,"tag":271,"props":862,"children":863},{"class":273,"line":292},[864],{"type":49,"tag":271,"props":865,"children":866},{},[867],{"type":55,"value":868},"    total_shares: u64,\n",{"type":49,"tag":271,"props":870,"children":871},{"class":273,"line":302},[872],{"type":49,"tag":271,"props":873,"children":874},{},[875],{"type":55,"value":876},"    total_assets: u64,\n",{"type":49,"tag":271,"props":878,"children":879},{"class":273,"line":311},[880],{"type":49,"tag":271,"props":881,"children":882},{},[883],{"type":55,"value":884},"    \u002F\u002F Computed on every update\n",{"type":49,"tag":271,"props":886,"children":887},{"class":273,"line":320},[888],{"type":49,"tag":271,"props":889,"children":890},{},[891],{"type":55,"value":892},"    share_price: u64,\n",{"type":49,"tag":271,"props":894,"children":895},{"class":273,"line":328},[896],{"type":49,"tag":271,"props":897,"children":898},{},[899],{"type":55,"value":570},{"type":49,"tag":271,"props":901,"children":902},{"class":273,"line":27},[903],{"type":49,"tag":271,"props":904,"children":905},{"emptyLinePlaceholder":296},[906],{"type":55,"value":299},{"type":49,"tag":271,"props":908,"children":909},{"class":273,"line":555},[910],{"type":49,"tag":271,"props":911,"children":912},{},[913],{"type":55,"value":914},"\u002F\u002F GOOD: Compute only when needed\n",{"type":49,"tag":271,"props":916,"children":917},{"class":273,"line":564},[918],{"type":49,"tag":271,"props":919,"children":920},{},[921],{"type":55,"value":860},{"type":49,"tag":271,"props":923,"children":924},{"class":273,"line":573},[925],{"type":49,"tag":271,"props":926,"children":927},{},[928],{"type":55,"value":868},{"type":49,"tag":271,"props":930,"children":931},{"class":273,"line":581},[932],{"type":49,"tag":271,"props":933,"children":934},{},[935],{"type":55,"value":876},{"type":49,"tag":271,"props":937,"children":938},{"class":273,"line":590},[939],{"type":49,"tag":271,"props":940,"children":941},{},[942],{"type":55,"value":943},"    \u002F\u002F Don't store computed values\n",{"type":49,"tag":271,"props":945,"children":946},{"class":273,"line":599},[947],{"type":49,"tag":271,"props":948,"children":949},{},[950],{"type":55,"value":570},{"type":49,"tag":271,"props":952,"children":953},{"class":273,"line":608},[954],{"type":49,"tag":271,"props":955,"children":956},{"emptyLinePlaceholder":296},[957],{"type":55,"value":299},{"type":49,"tag":271,"props":959,"children":960},{"class":273,"line":616},[961],{"type":49,"tag":271,"props":962,"children":963},{},[964],{"type":55,"value":965},"public fun get_share_price(pool_addr: address): u64 {\n",{"type":49,"tag":271,"props":967,"children":968},{"class":273,"line":624},[969],{"type":49,"tag":271,"props":970,"children":971},{},[972],{"type":55,"value":973},"    let pool = borrow_global\u003CPool>(pool_addr);\n",{"type":49,"tag":271,"props":975,"children":976},{"class":273,"line":23},[977],{"type":49,"tag":271,"props":978,"children":979},{},[980],{"type":55,"value":981},"    if (pool.total_shares == 0) {\n",{"type":49,"tag":271,"props":983,"children":984},{"class":273,"line":640},[985],{"type":49,"tag":271,"props":986,"children":987},{},[988],{"type":55,"value":989},"        INITIAL_SHARE_PRICE\n",{"type":49,"tag":271,"props":991,"children":992},{"class":273,"line":649},[993],{"type":49,"tag":271,"props":994,"children":995},{},[996],{"type":55,"value":997},"    } else {\n",{"type":49,"tag":271,"props":999,"children":1000},{"class":273,"line":657},[1001],{"type":49,"tag":271,"props":1002,"children":1003},{},[1004],{"type":55,"value":1005},"        pool.total_assets * PRECISION \u002F pool.total_shares\n",{"type":49,"tag":271,"props":1007,"children":1008},{"class":273,"line":665},[1009],{"type":49,"tag":271,"props":1010,"children":1011},{},[1012],{"type":55,"value":561},{"type":49,"tag":271,"props":1014,"children":1016},{"class":273,"line":1015},23,[1017],{"type":49,"tag":271,"props":1018,"children":1019},{},[1020],{"type":55,"value":570},{"type":49,"tag":254,"props":1022,"children":1024},{"id":1023},"_4-event-optimization",[1025],{"type":55,"value":1026},"4. Event Optimization",{"type":49,"tag":261,"props":1028,"children":1030},{"className":263,"code":1029,"language":39,"meta":265,"style":265},"\u002F\u002F BAD: Large event data\nstruct TradeEvent has drop, store {\n    pool: Object\u003CPool>,\n    trader: address,\n    token_in: Object\u003CToken>,\n    token_out: Object\u003CToken>,\n    amount_in: u64,\n    amount_out: u64,\n    fees: u64,\n    timestamp: u64,\n    metadata: vector\u003Cu8>, \u002F\u002F Large metadata\n}\n\n\u002F\u002F GOOD: Minimal event data\nstruct TradeEvent has drop, store {\n    pool_id: u64,        \u002F\u002F Use ID instead of Object\n    trader: address,\n    amounts: u128,       \u002F\u002F Pack amount_in and amount_out\n    fees: u64,\n    \u002F\u002F Compute other data from state\n}\n",[1031],{"type":49,"tag":220,"props":1032,"children":1033},{"__ignoreMap":265},[1034,1042,1050,1058,1066,1074,1082,1090,1098,1106,1113,1121,1128,1135,1143,1150,1158,1165,1173,1180,1188],{"type":49,"tag":271,"props":1035,"children":1036},{"class":273,"line":274},[1037],{"type":49,"tag":271,"props":1038,"children":1039},{},[1040],{"type":55,"value":1041},"\u002F\u002F BAD: Large event data\n",{"type":49,"tag":271,"props":1043,"children":1044},{"class":273,"line":283},[1045],{"type":49,"tag":271,"props":1046,"children":1047},{},[1048],{"type":55,"value":1049},"struct TradeEvent has drop, store {\n",{"type":49,"tag":271,"props":1051,"children":1052},{"class":273,"line":292},[1053],{"type":49,"tag":271,"props":1054,"children":1055},{},[1056],{"type":55,"value":1057},"    pool: Object\u003CPool>,\n",{"type":49,"tag":271,"props":1059,"children":1060},{"class":273,"line":302},[1061],{"type":49,"tag":271,"props":1062,"children":1063},{},[1064],{"type":55,"value":1065},"    trader: address,\n",{"type":49,"tag":271,"props":1067,"children":1068},{"class":273,"line":311},[1069],{"type":49,"tag":271,"props":1070,"children":1071},{},[1072],{"type":55,"value":1073},"    token_in: Object\u003CToken>,\n",{"type":49,"tag":271,"props":1075,"children":1076},{"class":273,"line":320},[1077],{"type":49,"tag":271,"props":1078,"children":1079},{},[1080],{"type":55,"value":1081},"    token_out: Object\u003CToken>,\n",{"type":49,"tag":271,"props":1083,"children":1084},{"class":273,"line":328},[1085],{"type":49,"tag":271,"props":1086,"children":1087},{},[1088],{"type":55,"value":1089},"    amount_in: u64,\n",{"type":49,"tag":271,"props":1091,"children":1092},{"class":273,"line":27},[1093],{"type":49,"tag":271,"props":1094,"children":1095},{},[1096],{"type":55,"value":1097},"    amount_out: u64,\n",{"type":49,"tag":271,"props":1099,"children":1100},{"class":273,"line":555},[1101],{"type":49,"tag":271,"props":1102,"children":1103},{},[1104],{"type":55,"value":1105},"    fees: u64,\n",{"type":49,"tag":271,"props":1107,"children":1108},{"class":273,"line":564},[1109],{"type":49,"tag":271,"props":1110,"children":1111},{},[1112],{"type":55,"value":816},{"type":49,"tag":271,"props":1114,"children":1115},{"class":273,"line":573},[1116],{"type":49,"tag":271,"props":1117,"children":1118},{},[1119],{"type":55,"value":1120},"    metadata: vector\u003Cu8>, \u002F\u002F Large metadata\n",{"type":49,"tag":271,"props":1122,"children":1123},{"class":273,"line":581},[1124],{"type":49,"tag":271,"props":1125,"children":1126},{},[1127],{"type":55,"value":570},{"type":49,"tag":271,"props":1129,"children":1130},{"class":273,"line":590},[1131],{"type":49,"tag":271,"props":1132,"children":1133},{"emptyLinePlaceholder":296},[1134],{"type":55,"value":299},{"type":49,"tag":271,"props":1136,"children":1137},{"class":273,"line":599},[1138],{"type":49,"tag":271,"props":1139,"children":1140},{},[1141],{"type":55,"value":1142},"\u002F\u002F GOOD: Minimal event data\n",{"type":49,"tag":271,"props":1144,"children":1145},{"class":273,"line":608},[1146],{"type":49,"tag":271,"props":1147,"children":1148},{},[1149],{"type":55,"value":1049},{"type":49,"tag":271,"props":1151,"children":1152},{"class":273,"line":616},[1153],{"type":49,"tag":271,"props":1154,"children":1155},{},[1156],{"type":55,"value":1157},"    pool_id: u64,        \u002F\u002F Use ID instead of Object\n",{"type":49,"tag":271,"props":1159,"children":1160},{"class":273,"line":624},[1161],{"type":49,"tag":271,"props":1162,"children":1163},{},[1164],{"type":55,"value":1065},{"type":49,"tag":271,"props":1166,"children":1167},{"class":273,"line":23},[1168],{"type":49,"tag":271,"props":1169,"children":1170},{},[1171],{"type":55,"value":1172},"    amounts: u128,       \u002F\u002F Pack amount_in and amount_out\n",{"type":49,"tag":271,"props":1174,"children":1175},{"class":273,"line":640},[1176],{"type":49,"tag":271,"props":1177,"children":1178},{},[1179],{"type":55,"value":1105},{"type":49,"tag":271,"props":1181,"children":1182},{"class":273,"line":649},[1183],{"type":49,"tag":271,"props":1184,"children":1185},{},[1186],{"type":55,"value":1187},"    \u002F\u002F Compute other data from state\n",{"type":49,"tag":271,"props":1189,"children":1190},{"class":273,"line":657},[1191],{"type":49,"tag":271,"props":1192,"children":1193},{},[1194],{"type":55,"value":570},{"type":49,"tag":254,"props":1196,"children":1198},{"id":1197},"_5-collection-optimization",[1199],{"type":55,"value":1200},"5. Collection Optimization",{"type":49,"tag":261,"props":1202,"children":1204},{"className":263,"code":1203,"language":39,"meta":265,"style":265},"\u002F\u002F BAD: Linear search\npublic fun find_item(items: &vector\u003CItem>, id: u64): Option\u003CItem> {\n    let i = 0;\n    while (i \u003C vector::length(items)) {\n        let item = vector::borrow(items, i);\n        if (item.id == id) {\n            return option::some(*item)\n        };\n        i = i + 1;\n    }\n    option::none()\n}\n\n\u002F\u002F GOOD: Use Table for O(1) lookup\nstruct Storage has key {\n    items: Table\u003Cu64, Item>,\n}\n\npublic fun find_item(storage: &Storage, id: u64): Option\u003CItem> {\n    if (table::contains(&storage.items, id)) {\n        option::some(*table::borrow(&storage.items, id))\n    } else {\n        option::none()\n    }\n}\n",[1205],{"type":49,"tag":220,"props":1206,"children":1207},{"__ignoreMap":265},[1208,1216,1224,1231,1239,1247,1255,1263,1271,1278,1285,1293,1300,1307,1315,1323,1331,1338,1345,1353,1361,1369,1376,1384,1392],{"type":49,"tag":271,"props":1209,"children":1210},{"class":273,"line":274},[1211],{"type":49,"tag":271,"props":1212,"children":1213},{},[1214],{"type":55,"value":1215},"\u002F\u002F BAD: Linear search\n",{"type":49,"tag":271,"props":1217,"children":1218},{"class":273,"line":283},[1219],{"type":49,"tag":271,"props":1220,"children":1221},{},[1222],{"type":55,"value":1223},"public fun find_item(items: &vector\u003CItem>, id: u64): Option\u003CItem> {\n",{"type":49,"tag":271,"props":1225,"children":1226},{"class":273,"line":292},[1227],{"type":49,"tag":271,"props":1228,"children":1229},{},[1230],{"type":55,"value":512},{"type":49,"tag":271,"props":1232,"children":1233},{"class":273,"line":302},[1234],{"type":49,"tag":271,"props":1235,"children":1236},{},[1237],{"type":55,"value":1238},"    while (i \u003C vector::length(items)) {\n",{"type":49,"tag":271,"props":1240,"children":1241},{"class":273,"line":311},[1242],{"type":49,"tag":271,"props":1243,"children":1244},{},[1245],{"type":55,"value":1246},"        let item = vector::borrow(items, i);\n",{"type":49,"tag":271,"props":1248,"children":1249},{"class":273,"line":320},[1250],{"type":49,"tag":271,"props":1251,"children":1252},{},[1253],{"type":55,"value":1254},"        if (item.id == id) {\n",{"type":49,"tag":271,"props":1256,"children":1257},{"class":273,"line":328},[1258],{"type":49,"tag":271,"props":1259,"children":1260},{},[1261],{"type":55,"value":1262},"            return option::some(*item)\n",{"type":49,"tag":271,"props":1264,"children":1265},{"class":273,"line":27},[1266],{"type":49,"tag":271,"props":1267,"children":1268},{},[1269],{"type":55,"value":1270},"        };\n",{"type":49,"tag":271,"props":1272,"children":1273},{"class":273,"line":555},[1274],{"type":49,"tag":271,"props":1275,"children":1276},{},[1277],{"type":55,"value":552},{"type":49,"tag":271,"props":1279,"children":1280},{"class":273,"line":564},[1281],{"type":49,"tag":271,"props":1282,"children":1283},{},[1284],{"type":55,"value":561},{"type":49,"tag":271,"props":1286,"children":1287},{"class":273,"line":573},[1288],{"type":49,"tag":271,"props":1289,"children":1290},{},[1291],{"type":55,"value":1292},"    option::none()\n",{"type":49,"tag":271,"props":1294,"children":1295},{"class":273,"line":581},[1296],{"type":49,"tag":271,"props":1297,"children":1298},{},[1299],{"type":55,"value":570},{"type":49,"tag":271,"props":1301,"children":1302},{"class":273,"line":590},[1303],{"type":49,"tag":271,"props":1304,"children":1305},{"emptyLinePlaceholder":296},[1306],{"type":55,"value":299},{"type":49,"tag":271,"props":1308,"children":1309},{"class":273,"line":599},[1310],{"type":49,"tag":271,"props":1311,"children":1312},{},[1313],{"type":55,"value":1314},"\u002F\u002F GOOD: Use Table for O(1) lookup\n",{"type":49,"tag":271,"props":1316,"children":1317},{"class":273,"line":608},[1318],{"type":49,"tag":271,"props":1319,"children":1320},{},[1321],{"type":55,"value":1322},"struct Storage has key {\n",{"type":49,"tag":271,"props":1324,"children":1325},{"class":273,"line":616},[1326],{"type":49,"tag":271,"props":1327,"children":1328},{},[1329],{"type":55,"value":1330},"    items: Table\u003Cu64, Item>,\n",{"type":49,"tag":271,"props":1332,"children":1333},{"class":273,"line":624},[1334],{"type":49,"tag":271,"props":1335,"children":1336},{},[1337],{"type":55,"value":570},{"type":49,"tag":271,"props":1339,"children":1340},{"class":273,"line":23},[1341],{"type":49,"tag":271,"props":1342,"children":1343},{"emptyLinePlaceholder":296},[1344],{"type":55,"value":299},{"type":49,"tag":271,"props":1346,"children":1347},{"class":273,"line":640},[1348],{"type":49,"tag":271,"props":1349,"children":1350},{},[1351],{"type":55,"value":1352},"public fun find_item(storage: &Storage, id: u64): Option\u003CItem> {\n",{"type":49,"tag":271,"props":1354,"children":1355},{"class":273,"line":649},[1356],{"type":49,"tag":271,"props":1357,"children":1358},{},[1359],{"type":55,"value":1360},"    if (table::contains(&storage.items, id)) {\n",{"type":49,"tag":271,"props":1362,"children":1363},{"class":273,"line":657},[1364],{"type":49,"tag":271,"props":1365,"children":1366},{},[1367],{"type":55,"value":1368},"        option::some(*table::borrow(&storage.items, id))\n",{"type":49,"tag":271,"props":1370,"children":1371},{"class":273,"line":665},[1372],{"type":49,"tag":271,"props":1373,"children":1374},{},[1375],{"type":55,"value":997},{"type":49,"tag":271,"props":1377,"children":1378},{"class":273,"line":1015},[1379],{"type":49,"tag":271,"props":1380,"children":1381},{},[1382],{"type":55,"value":1383},"        option::none()\n",{"type":49,"tag":271,"props":1385,"children":1387},{"class":273,"line":1386},24,[1388],{"type":49,"tag":271,"props":1389,"children":1390},{},[1391],{"type":55,"value":561},{"type":49,"tag":271,"props":1393,"children":1395},{"class":273,"line":1394},25,[1396],{"type":49,"tag":271,"props":1397,"children":1398},{},[1399],{"type":55,"value":570},{"type":49,"tag":64,"props":1401,"children":1403},{"id":1402},"gas-measurement",[1404],{"type":55,"value":1405},"Gas Measurement",{"type":49,"tag":142,"props":1407,"children":1409},{"id":1408},"_1-transaction-simulation",[1410],{"type":55,"value":1411},"1. Transaction Simulation",{"type":49,"tag":261,"props":1413,"children":1417},{"className":1414,"code":1415,"language":1416,"meta":265,"style":265},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Simulate to get gas estimate\naptos move run-function \\\n    --function-id 0x1::module::function \\\n    --args ... \\\n    --simulate\n\n# Output includes:\n# - gas_unit_price\n# - max_gas_amount\n# - gas_used\n","bash",[1418],{"type":49,"tag":220,"props":1419,"children":1420},{"__ignoreMap":265},[1421,1430,1455,1472,1489,1497,1504,1512,1520,1528],{"type":49,"tag":271,"props":1422,"children":1423},{"class":273,"line":274},[1424],{"type":49,"tag":271,"props":1425,"children":1427},{"style":1426},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[1428],{"type":55,"value":1429},"# Simulate to get gas estimate\n",{"type":49,"tag":271,"props":1431,"children":1432},{"class":273,"line":283},[1433,1438,1444,1449],{"type":49,"tag":271,"props":1434,"children":1436},{"style":1435},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[1437],{"type":55,"value":8},{"type":49,"tag":271,"props":1439,"children":1441},{"style":1440},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[1442],{"type":55,"value":1443}," move",{"type":49,"tag":271,"props":1445,"children":1446},{"style":1440},[1447],{"type":55,"value":1448}," run-function",{"type":49,"tag":271,"props":1450,"children":1452},{"style":1451},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[1453],{"type":55,"value":1454}," \\\n",{"type":49,"tag":271,"props":1456,"children":1457},{"class":273,"line":292},[1458,1463,1468],{"type":49,"tag":271,"props":1459,"children":1460},{"style":1440},[1461],{"type":55,"value":1462},"    --function-id",{"type":49,"tag":271,"props":1464,"children":1465},{"style":1440},[1466],{"type":55,"value":1467}," 0x1::module::function",{"type":49,"tag":271,"props":1469,"children":1470},{"style":1451},[1471],{"type":55,"value":1454},{"type":49,"tag":271,"props":1473,"children":1474},{"class":273,"line":302},[1475,1480,1485],{"type":49,"tag":271,"props":1476,"children":1477},{"style":1440},[1478],{"type":55,"value":1479},"    --args",{"type":49,"tag":271,"props":1481,"children":1482},{"style":1440},[1483],{"type":55,"value":1484}," ...",{"type":49,"tag":271,"props":1486,"children":1487},{"style":1451},[1488],{"type":55,"value":1454},{"type":49,"tag":271,"props":1490,"children":1491},{"class":273,"line":311},[1492],{"type":49,"tag":271,"props":1493,"children":1494},{"style":1440},[1495],{"type":55,"value":1496},"    --simulate\n",{"type":49,"tag":271,"props":1498,"children":1499},{"class":273,"line":320},[1500],{"type":49,"tag":271,"props":1501,"children":1502},{"emptyLinePlaceholder":296},[1503],{"type":55,"value":299},{"type":49,"tag":271,"props":1505,"children":1506},{"class":273,"line":328},[1507],{"type":49,"tag":271,"props":1508,"children":1509},{"style":1426},[1510],{"type":55,"value":1511},"# Output includes:\n",{"type":49,"tag":271,"props":1513,"children":1514},{"class":273,"line":27},[1515],{"type":49,"tag":271,"props":1516,"children":1517},{"style":1426},[1518],{"type":55,"value":1519},"# - gas_unit_price\n",{"type":49,"tag":271,"props":1521,"children":1522},{"class":273,"line":555},[1523],{"type":49,"tag":271,"props":1524,"children":1525},{"style":1426},[1526],{"type":55,"value":1527},"# - max_gas_amount\n",{"type":49,"tag":271,"props":1529,"children":1530},{"class":273,"line":564},[1531],{"type":49,"tag":271,"props":1532,"children":1533},{"style":1426},[1534],{"type":55,"value":1535},"# - gas_used\n",{"type":49,"tag":142,"props":1537,"children":1539},{"id":1538},"_2-gas-profiling",[1540],{"type":55,"value":1541},"2. Gas Profiling",{"type":49,"tag":261,"props":1543,"children":1545},{"className":263,"code":1544,"language":39,"meta":265,"style":265},"#[test]\npublic fun test_gas_usage() {\n    \u002F\u002F Measure gas for operation\n    let gas_before = gas::remaining_gas();\n    expensive_operation();\n    let gas_used = gas_before - gas::remaining_gas();\n\n    \u002F\u002F Assert reasonable gas usage\n    assert!(gas_used \u003C MAX_ACCEPTABLE_GAS, E_TOO_EXPENSIVE);\n}\n",[1546],{"type":49,"tag":220,"props":1547,"children":1548},{"__ignoreMap":265},[1549,1557,1565,1573,1581,1589,1597,1604,1612,1620],{"type":49,"tag":271,"props":1550,"children":1551},{"class":273,"line":274},[1552],{"type":49,"tag":271,"props":1553,"children":1554},{},[1555],{"type":55,"value":1556},"#[test]\n",{"type":49,"tag":271,"props":1558,"children":1559},{"class":273,"line":283},[1560],{"type":49,"tag":271,"props":1561,"children":1562},{},[1563],{"type":55,"value":1564},"public fun test_gas_usage() {\n",{"type":49,"tag":271,"props":1566,"children":1567},{"class":273,"line":292},[1568],{"type":49,"tag":271,"props":1569,"children":1570},{},[1571],{"type":55,"value":1572},"    \u002F\u002F Measure gas for operation\n",{"type":49,"tag":271,"props":1574,"children":1575},{"class":273,"line":302},[1576],{"type":49,"tag":271,"props":1577,"children":1578},{},[1579],{"type":55,"value":1580},"    let gas_before = gas::remaining_gas();\n",{"type":49,"tag":271,"props":1582,"children":1583},{"class":273,"line":311},[1584],{"type":49,"tag":271,"props":1585,"children":1586},{},[1587],{"type":55,"value":1588},"    expensive_operation();\n",{"type":49,"tag":271,"props":1590,"children":1591},{"class":273,"line":320},[1592],{"type":49,"tag":271,"props":1593,"children":1594},{},[1595],{"type":55,"value":1596},"    let gas_used = gas_before - gas::remaining_gas();\n",{"type":49,"tag":271,"props":1598,"children":1599},{"class":273,"line":328},[1600],{"type":49,"tag":271,"props":1601,"children":1602},{"emptyLinePlaceholder":296},[1603],{"type":55,"value":299},{"type":49,"tag":271,"props":1605,"children":1606},{"class":273,"line":27},[1607],{"type":49,"tag":271,"props":1608,"children":1609},{},[1610],{"type":55,"value":1611},"    \u002F\u002F Assert reasonable gas usage\n",{"type":49,"tag":271,"props":1613,"children":1614},{"class":273,"line":555},[1615],{"type":49,"tag":271,"props":1616,"children":1617},{},[1618],{"type":55,"value":1619},"    assert!(gas_used \u003C MAX_ACCEPTABLE_GAS, E_TOO_EXPENSIVE);\n",{"type":49,"tag":271,"props":1621,"children":1622},{"class":273,"line":564},[1623],{"type":49,"tag":271,"props":1624,"children":1625},{},[1626],{"type":55,"value":570},{"type":49,"tag":64,"props":1628,"children":1630},{"id":1629},"optimization-checklist",[1631],{"type":55,"value":1632},"Optimization Checklist",{"type":49,"tag":142,"props":1634,"children":1636},{"id":1635},"storage-checklist",[1637],{"type":55,"value":1638},"Storage Checklist",{"type":49,"tag":80,"props":1640,"children":1643},{"className":1641},[1642],"contains-task-list",[1644,1656,1665,1674,1683],{"type":49,"tag":84,"props":1645,"children":1648},{"className":1646},[1647],"task-list-item",[1649,1654],{"type":49,"tag":1650,"props":1651,"children":1653},"input",{"disabled":296,"type":1652},"checkbox",[],{"type":55,"value":1655}," Pack struct fields to minimize size",{"type":49,"tag":84,"props":1657,"children":1659},{"className":1658},[1647],[1660,1663],{"type":49,"tag":1650,"props":1661,"children":1662},{"disabled":296,"type":1652},[],{"type":55,"value":1664}," Use appropriate integer sizes (u8, u16, u32, u64)",{"type":49,"tag":84,"props":1666,"children":1668},{"className":1667},[1647],[1669,1672],{"type":49,"tag":1650,"props":1670,"children":1671},{"disabled":296,"type":1652},[],{"type":55,"value":1673}," Remove unnecessary fields",{"type":49,"tag":84,"props":1675,"children":1677},{"className":1676},[1647],[1678,1681],{"type":49,"tag":1650,"props":1679,"children":1680},{"disabled":296,"type":1652},[],{"type":55,"value":1682}," Consider off-chain storage for large data",{"type":49,"tag":84,"props":1684,"children":1686},{"className":1685},[1647],[1687,1690],{"type":49,"tag":1650,"props":1688,"children":1689},{"disabled":296,"type":1652},[],{"type":55,"value":1691}," Use events instead of storage for logs",{"type":49,"tag":142,"props":1693,"children":1695},{"id":1694},"computation-checklist",[1696],{"type":55,"value":1697},"Computation Checklist",{"type":49,"tag":80,"props":1699,"children":1701},{"className":1700},[1642],[1702,1711,1720,1729,1738],{"type":49,"tag":84,"props":1703,"children":1705},{"className":1704},[1647],[1706,1709],{"type":49,"tag":1650,"props":1707,"children":1708},{"disabled":296,"type":1652},[],{"type":55,"value":1710}," Cache repeated calculations",{"type":49,"tag":84,"props":1712,"children":1714},{"className":1713},[1647],[1715,1718],{"type":49,"tag":1650,"props":1716,"children":1717},{"disabled":296,"type":1652},[],{"type":55,"value":1719}," Minimize loops over collections",{"type":49,"tag":84,"props":1721,"children":1723},{"className":1722},[1647],[1724,1727],{"type":49,"tag":1650,"props":1725,"children":1726},{"disabled":296,"type":1652},[],{"type":55,"value":1728}," Use early returns to skip unnecessary work",{"type":49,"tag":84,"props":1730,"children":1732},{"className":1731},[1647],[1733,1736],{"type":49,"tag":1650,"props":1734,"children":1735},{"disabled":296,"type":1652},[],{"type":55,"value":1737}," Batch similar operations",{"type":49,"tag":84,"props":1739,"children":1741},{"className":1740},[1647],[1742,1745],{"type":49,"tag":1650,"props":1743,"children":1744},{"disabled":296,"type":1652},[],{"type":55,"value":1746}," Avoid redundant checks",{"type":49,"tag":142,"props":1748,"children":1750},{"id":1749},"collection-checklist",[1751],{"type":55,"value":1752},"Collection Checklist",{"type":49,"tag":80,"props":1754,"children":1756},{"className":1755},[1642],[1757,1766,1775,1784,1793],{"type":49,"tag":84,"props":1758,"children":1760},{"className":1759},[1647],[1761,1764],{"type":49,"tag":1650,"props":1762,"children":1763},{"disabled":296,"type":1652},[],{"type":55,"value":1765}," Use Table\u002FTableWithLength for key-value lookups",{"type":49,"tag":84,"props":1767,"children":1769},{"className":1768},[1647],[1770,1773],{"type":49,"tag":1650,"props":1771,"children":1772},{"disabled":296,"type":1652},[],{"type":55,"value":1774}," Use SmartTable for large collections",{"type":49,"tag":84,"props":1776,"children":1778},{"className":1777},[1647],[1779,1782],{"type":49,"tag":1650,"props":1780,"children":1781},{"disabled":296,"type":1652},[],{"type":55,"value":1783}," Limit vector sizes",{"type":49,"tag":84,"props":1785,"children":1787},{"className":1786},[1647],[1788,1791],{"type":49,"tag":1650,"props":1789,"children":1790},{"disabled":296,"type":1652},[],{"type":55,"value":1792}," Consider pagination for large results",{"type":49,"tag":84,"props":1794,"children":1796},{"className":1795},[1647],[1797,1800],{"type":49,"tag":1650,"props":1798,"children":1799},{"disabled":296,"type":1652},[],{"type":55,"value":1801}," Use appropriate data structures",{"type":49,"tag":142,"props":1803,"children":1805},{"id":1804},"best-practices",[1806],{"type":55,"value":1807},"Best Practices",{"type":49,"tag":80,"props":1809,"children":1811},{"className":1810},[1642],[1812,1821,1830,1839,1848],{"type":49,"tag":84,"props":1813,"children":1815},{"className":1814},[1647],[1816,1819],{"type":49,"tag":1650,"props":1817,"children":1818},{"disabled":296,"type":1652},[],{"type":55,"value":1820}," Profile before and after optimization",{"type":49,"tag":84,"props":1822,"children":1824},{"className":1823},[1647],[1825,1828],{"type":49,"tag":1650,"props":1826,"children":1827},{"disabled":296,"type":1652},[],{"type":55,"value":1829}," Test gas usage in unit tests",{"type":49,"tag":84,"props":1831,"children":1833},{"className":1832},[1647],[1834,1837],{"type":49,"tag":1650,"props":1835,"children":1836},{"disabled":296,"type":1652},[],{"type":55,"value":1838}," Document gas costs for public functions",{"type":49,"tag":84,"props":1840,"children":1842},{"className":1841},[1647],[1843,1846],{"type":49,"tag":1650,"props":1844,"children":1845},{"disabled":296,"type":1652},[],{"type":55,"value":1847}," Consider gas costs in contract design",{"type":49,"tag":84,"props":1849,"children":1851},{"className":1850},[1647],[1852,1855],{"type":49,"tag":1650,"props":1853,"children":1854},{"disabled":296,"type":1652},[],{"type":55,"value":1856}," Monitor mainnet gas usage",{"type":49,"tag":64,"props":1858,"children":1860},{"id":1859},"common-gas-optimizations",[1861],{"type":55,"value":1862},"Common Gas Optimizations",{"type":49,"tag":142,"props":1864,"children":1866},{"id":1865},"_1-replace-vectors-with-tables",[1867],{"type":55,"value":1868},"1. Replace Vectors with Tables",{"type":49,"tag":261,"props":1870,"children":1872},{"className":263,"code":1871,"language":39,"meta":265,"style":265},"\u002F\u002F Before: O(n) search\nstruct Registry has key {\n    users: vector\u003CUser>,\n}\n\n\u002F\u002F After: O(1) lookup\nstruct Registry has key {\n    users: Table\u003Caddress, User>,\n    user_list: vector\u003Caddress>, \u002F\u002F If iteration needed\n}\n",[1873],{"type":49,"tag":220,"props":1874,"children":1875},{"__ignoreMap":265},[1876,1884,1892,1900,1907,1914,1922,1929,1937,1945],{"type":49,"tag":271,"props":1877,"children":1878},{"class":273,"line":274},[1879],{"type":49,"tag":271,"props":1880,"children":1881},{},[1882],{"type":55,"value":1883},"\u002F\u002F Before: O(n) search\n",{"type":49,"tag":271,"props":1885,"children":1886},{"class":273,"line":283},[1887],{"type":49,"tag":271,"props":1888,"children":1889},{},[1890],{"type":55,"value":1891},"struct Registry has key {\n",{"type":49,"tag":271,"props":1893,"children":1894},{"class":273,"line":292},[1895],{"type":49,"tag":271,"props":1896,"children":1897},{},[1898],{"type":55,"value":1899},"    users: vector\u003CUser>,\n",{"type":49,"tag":271,"props":1901,"children":1902},{"class":273,"line":302},[1903],{"type":49,"tag":271,"props":1904,"children":1905},{},[1906],{"type":55,"value":570},{"type":49,"tag":271,"props":1908,"children":1909},{"class":273,"line":311},[1910],{"type":49,"tag":271,"props":1911,"children":1912},{"emptyLinePlaceholder":296},[1913],{"type":55,"value":299},{"type":49,"tag":271,"props":1915,"children":1916},{"class":273,"line":320},[1917],{"type":49,"tag":271,"props":1918,"children":1919},{},[1920],{"type":55,"value":1921},"\u002F\u002F After: O(1) lookup\n",{"type":49,"tag":271,"props":1923,"children":1924},{"class":273,"line":328},[1925],{"type":49,"tag":271,"props":1926,"children":1927},{},[1928],{"type":55,"value":1891},{"type":49,"tag":271,"props":1930,"children":1931},{"class":273,"line":27},[1932],{"type":49,"tag":271,"props":1933,"children":1934},{},[1935],{"type":55,"value":1936},"    users: Table\u003Caddress, User>,\n",{"type":49,"tag":271,"props":1938,"children":1939},{"class":273,"line":555},[1940],{"type":49,"tag":271,"props":1941,"children":1942},{},[1943],{"type":55,"value":1944},"    user_list: vector\u003Caddress>, \u002F\u002F If iteration needed\n",{"type":49,"tag":271,"props":1946,"children":1947},{"class":273,"line":564},[1948],{"type":49,"tag":271,"props":1949,"children":1950},{},[1951],{"type":55,"value":570},{"type":49,"tag":142,"props":1953,"children":1955},{"id":1954},"_2-minimize-storage-reads",[1956],{"type":55,"value":1957},"2. Minimize Storage Reads",{"type":49,"tag":261,"props":1959,"children":1961},{"className":263,"code":1960,"language":39,"meta":265,"style":265},"\u002F\u002F Before: Multiple reads\npublic fun transfer(from: &signer, to: address, amount: u64) {\n    assert!(get_balance(signer::address_of(from)) >= amount, E_INSUFFICIENT);\n    let from_balance = borrow_global_mut\u003CBalance>(signer::address_of(from));\n    let to_balance = borrow_global_mut\u003CBalance>(to);\n    \u002F\u002F ...\n}\n\n\u002F\u002F After: Single read with validation\npublic fun transfer(from: &signer, to: address, amount: u64) {\n    let from_addr = signer::address_of(from);\n    let from_balance = borrow_global_mut\u003CBalance>(from_addr);\n    assert!(from_balance.value >= amount, E_INSUFFICIENT);\n    \u002F\u002F ... rest of logic\n}\n",[1962],{"type":49,"tag":220,"props":1963,"children":1964},{"__ignoreMap":265},[1965,1973,1981,1989,1997,2005,2013,2020,2027,2035,2042,2050,2058,2066,2074],{"type":49,"tag":271,"props":1966,"children":1967},{"class":273,"line":274},[1968],{"type":49,"tag":271,"props":1969,"children":1970},{},[1971],{"type":55,"value":1972},"\u002F\u002F Before: Multiple reads\n",{"type":49,"tag":271,"props":1974,"children":1975},{"class":273,"line":283},[1976],{"type":49,"tag":271,"props":1977,"children":1978},{},[1979],{"type":55,"value":1980},"public fun transfer(from: &signer, to: address, amount: u64) {\n",{"type":49,"tag":271,"props":1982,"children":1983},{"class":273,"line":292},[1984],{"type":49,"tag":271,"props":1985,"children":1986},{},[1987],{"type":55,"value":1988},"    assert!(get_balance(signer::address_of(from)) >= amount, E_INSUFFICIENT);\n",{"type":49,"tag":271,"props":1990,"children":1991},{"class":273,"line":302},[1992],{"type":49,"tag":271,"props":1993,"children":1994},{},[1995],{"type":55,"value":1996},"    let from_balance = borrow_global_mut\u003CBalance>(signer::address_of(from));\n",{"type":49,"tag":271,"props":1998,"children":1999},{"class":273,"line":311},[2000],{"type":49,"tag":271,"props":2001,"children":2002},{},[2003],{"type":55,"value":2004},"    let to_balance = borrow_global_mut\u003CBalance>(to);\n",{"type":49,"tag":271,"props":2006,"children":2007},{"class":273,"line":320},[2008],{"type":49,"tag":271,"props":2009,"children":2010},{},[2011],{"type":55,"value":2012},"    \u002F\u002F ...\n",{"type":49,"tag":271,"props":2014,"children":2015},{"class":273,"line":328},[2016],{"type":49,"tag":271,"props":2017,"children":2018},{},[2019],{"type":55,"value":570},{"type":49,"tag":271,"props":2021,"children":2022},{"class":273,"line":27},[2023],{"type":49,"tag":271,"props":2024,"children":2025},{"emptyLinePlaceholder":296},[2026],{"type":55,"value":299},{"type":49,"tag":271,"props":2028,"children":2029},{"class":273,"line":555},[2030],{"type":49,"tag":271,"props":2031,"children":2032},{},[2033],{"type":55,"value":2034},"\u002F\u002F After: Single read with validation\n",{"type":49,"tag":271,"props":2036,"children":2037},{"class":273,"line":564},[2038],{"type":49,"tag":271,"props":2039,"children":2040},{},[2041],{"type":55,"value":1980},{"type":49,"tag":271,"props":2043,"children":2044},{"class":273,"line":573},[2045],{"type":49,"tag":271,"props":2046,"children":2047},{},[2048],{"type":55,"value":2049},"    let from_addr = signer::address_of(from);\n",{"type":49,"tag":271,"props":2051,"children":2052},{"class":273,"line":581},[2053],{"type":49,"tag":271,"props":2054,"children":2055},{},[2056],{"type":55,"value":2057},"    let from_balance = borrow_global_mut\u003CBalance>(from_addr);\n",{"type":49,"tag":271,"props":2059,"children":2060},{"class":273,"line":590},[2061],{"type":49,"tag":271,"props":2062,"children":2063},{},[2064],{"type":55,"value":2065},"    assert!(from_balance.value >= amount, E_INSUFFICIENT);\n",{"type":49,"tag":271,"props":2067,"children":2068},{"class":273,"line":599},[2069],{"type":49,"tag":271,"props":2070,"children":2071},{},[2072],{"type":55,"value":2073},"    \u002F\u002F ... rest of logic\n",{"type":49,"tag":271,"props":2075,"children":2076},{"class":273,"line":608},[2077],{"type":49,"tag":271,"props":2078,"children":2079},{},[2080],{"type":55,"value":570},{"type":49,"tag":142,"props":2082,"children":2084},{"id":2083},"_3-use-bitwise-flags",[2085],{"type":55,"value":2086},"3. Use Bitwise Flags",{"type":49,"tag":261,"props":2088,"children":2090},{"className":263,"code":2089,"language":39,"meta":265,"style":265},"\u002F\u002F Before: Multiple bool fields (8 bytes each)\nstruct Settings has copy, drop, store {\n    is_active: bool,\n    is_paused: bool,\n    is_initialized: bool,\n    allows_deposits: bool,\n}\n\n\u002F\u002F After: Single u8 (1 byte)\nstruct Settings has copy, drop, store {\n    flags: u8, \u002F\u002F Bit 0: active, 1: paused, 2: initialized, 3: deposits\n}\n\nconst FLAG_ACTIVE: u8 = 1;        \u002F\u002F 0b00000001\nconst FLAG_PAUSED: u8 = 2;        \u002F\u002F 0b00000010\nconst FLAG_INITIALIZED: u8 = 4;   \u002F\u002F 0b00000100\nconst FLAG_DEPOSITS: u8 = 8;      \u002F\u002F 0b00001000\n\npublic fun is_active(settings: &Settings): bool {\n    (settings.flags & FLAG_ACTIVE) != 0\n}\n",[2091],{"type":49,"tag":220,"props":2092,"children":2093},{"__ignoreMap":265},[2094,2102,2110,2118,2126,2134,2142,2149,2156,2164,2171,2179,2186,2193,2201,2209,2217,2225,2232,2240,2248],{"type":49,"tag":271,"props":2095,"children":2096},{"class":273,"line":274},[2097],{"type":49,"tag":271,"props":2098,"children":2099},{},[2100],{"type":55,"value":2101},"\u002F\u002F Before: Multiple bool fields (8 bytes each)\n",{"type":49,"tag":271,"props":2103,"children":2104},{"class":273,"line":283},[2105],{"type":49,"tag":271,"props":2106,"children":2107},{},[2108],{"type":55,"value":2109},"struct Settings has copy, drop, store {\n",{"type":49,"tag":271,"props":2111,"children":2112},{"class":273,"line":292},[2113],{"type":49,"tag":271,"props":2114,"children":2115},{},[2116],{"type":55,"value":2117},"    is_active: bool,\n",{"type":49,"tag":271,"props":2119,"children":2120},{"class":273,"line":302},[2121],{"type":49,"tag":271,"props":2122,"children":2123},{},[2124],{"type":55,"value":2125},"    is_paused: bool,\n",{"type":49,"tag":271,"props":2127,"children":2128},{"class":273,"line":311},[2129],{"type":49,"tag":271,"props":2130,"children":2131},{},[2132],{"type":55,"value":2133},"    is_initialized: bool,\n",{"type":49,"tag":271,"props":2135,"children":2136},{"class":273,"line":320},[2137],{"type":49,"tag":271,"props":2138,"children":2139},{},[2140],{"type":55,"value":2141},"    allows_deposits: bool,\n",{"type":49,"tag":271,"props":2143,"children":2144},{"class":273,"line":328},[2145],{"type":49,"tag":271,"props":2146,"children":2147},{},[2148],{"type":55,"value":570},{"type":49,"tag":271,"props":2150,"children":2151},{"class":273,"line":27},[2152],{"type":49,"tag":271,"props":2153,"children":2154},{"emptyLinePlaceholder":296},[2155],{"type":55,"value":299},{"type":49,"tag":271,"props":2157,"children":2158},{"class":273,"line":555},[2159],{"type":49,"tag":271,"props":2160,"children":2161},{},[2162],{"type":55,"value":2163},"\u002F\u002F After: Single u8 (1 byte)\n",{"type":49,"tag":271,"props":2165,"children":2166},{"class":273,"line":564},[2167],{"type":49,"tag":271,"props":2168,"children":2169},{},[2170],{"type":55,"value":2109},{"type":49,"tag":271,"props":2172,"children":2173},{"class":273,"line":573},[2174],{"type":49,"tag":271,"props":2175,"children":2176},{},[2177],{"type":55,"value":2178},"    flags: u8, \u002F\u002F Bit 0: active, 1: paused, 2: initialized, 3: deposits\n",{"type":49,"tag":271,"props":2180,"children":2181},{"class":273,"line":581},[2182],{"type":49,"tag":271,"props":2183,"children":2184},{},[2185],{"type":55,"value":570},{"type":49,"tag":271,"props":2187,"children":2188},{"class":273,"line":590},[2189],{"type":49,"tag":271,"props":2190,"children":2191},{"emptyLinePlaceholder":296},[2192],{"type":55,"value":299},{"type":49,"tag":271,"props":2194,"children":2195},{"class":273,"line":599},[2196],{"type":49,"tag":271,"props":2197,"children":2198},{},[2199],{"type":55,"value":2200},"const FLAG_ACTIVE: u8 = 1;        \u002F\u002F 0b00000001\n",{"type":49,"tag":271,"props":2202,"children":2203},{"class":273,"line":608},[2204],{"type":49,"tag":271,"props":2205,"children":2206},{},[2207],{"type":55,"value":2208},"const FLAG_PAUSED: u8 = 2;        \u002F\u002F 0b00000010\n",{"type":49,"tag":271,"props":2210,"children":2211},{"class":273,"line":616},[2212],{"type":49,"tag":271,"props":2213,"children":2214},{},[2215],{"type":55,"value":2216},"const FLAG_INITIALIZED: u8 = 4;   \u002F\u002F 0b00000100\n",{"type":49,"tag":271,"props":2218,"children":2219},{"class":273,"line":624},[2220],{"type":49,"tag":271,"props":2221,"children":2222},{},[2223],{"type":55,"value":2224},"const FLAG_DEPOSITS: u8 = 8;      \u002F\u002F 0b00001000\n",{"type":49,"tag":271,"props":2226,"children":2227},{"class":273,"line":23},[2228],{"type":49,"tag":271,"props":2229,"children":2230},{"emptyLinePlaceholder":296},[2231],{"type":55,"value":299},{"type":49,"tag":271,"props":2233,"children":2234},{"class":273,"line":640},[2235],{"type":49,"tag":271,"props":2236,"children":2237},{},[2238],{"type":55,"value":2239},"public fun is_active(settings: &Settings): bool {\n",{"type":49,"tag":271,"props":2241,"children":2242},{"class":273,"line":649},[2243],{"type":49,"tag":271,"props":2244,"children":2245},{},[2246],{"type":55,"value":2247},"    (settings.flags & FLAG_ACTIVE) != 0\n",{"type":49,"tag":271,"props":2249,"children":2250},{"class":273,"line":657},[2251],{"type":49,"tag":271,"props":2252,"children":2253},{},[2254],{"type":55,"value":570},{"type":49,"tag":64,"props":2256,"children":2258},{"id":2257},"gas-optimization-report-template",[2259],{"type":55,"value":2260},"Gas Optimization Report Template",{"type":49,"tag":261,"props":2262,"children":2266},{"className":2263,"code":2264,"language":2265,"meta":265,"style":265},"language-markdown shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Gas Optimization Report\n\n## Summary\n\n- Current average gas: X units\n- Optimized average gas: Y units\n- Savings: Z% reduction\n\n## Optimizations Applied\n\n### 1. Storage Optimization\n\n- Packed struct fields (saved X bytes)\n- Replaced vectors with tables (O(n) → O(1))\n- Removed redundant fields\n\n### 2. Computation Optimization\n\n- Cached price calculations (saved X operations)\n- Batched updates (N calls → 1 call)\n- Early returns in validation\n\n### 3. Event Optimization\n\n- Reduced event size from X to Y bytes\n- Removed redundant event fields\n\n## Measurements\n\n| Function | Before | After  | Savings |\n| -------- | ------ | ------ | ------- |\n| mint     | 50,000 | 35,000 | 30%     |\n| transfer | 30,000 | 25,000 | 17%     |\n| swap     | 80,000 | 60,000 | 25%     |\n\n## Recommendations\n\n1. Consider further optimizations for high-frequency functions\n2. Monitor mainnet usage patterns\n3. Set up gas usage alerts\n","markdown",[2267],{"type":49,"tag":220,"props":2268,"children":2269},{"__ignoreMap":265},[2270,2284,2291,2304,2311,2324,2336,2348,2355,2367,2374,2387,2394,2406,2418,2430,2437,2449,2456,2468,2480,2492,2499,2511,2518,2530,2543,2551,2564,2572,2618,2663,2707,2751,2795,2803,2816,2824,2838,2852],{"type":49,"tag":271,"props":2271,"children":2272},{"class":273,"line":274},[2273,2279],{"type":49,"tag":271,"props":2274,"children":2276},{"style":2275},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[2277],{"type":55,"value":2278},"# ",{"type":49,"tag":271,"props":2280,"children":2281},{"style":1435},[2282],{"type":55,"value":2283},"Gas Optimization Report\n",{"type":49,"tag":271,"props":2285,"children":2286},{"class":273,"line":283},[2287],{"type":49,"tag":271,"props":2288,"children":2289},{"emptyLinePlaceholder":296},[2290],{"type":55,"value":299},{"type":49,"tag":271,"props":2292,"children":2293},{"class":273,"line":292},[2294,2299],{"type":49,"tag":271,"props":2295,"children":2296},{"style":2275},[2297],{"type":55,"value":2298},"## ",{"type":49,"tag":271,"props":2300,"children":2301},{"style":1435},[2302],{"type":55,"value":2303},"Summary\n",{"type":49,"tag":271,"props":2305,"children":2306},{"class":273,"line":302},[2307],{"type":49,"tag":271,"props":2308,"children":2309},{"emptyLinePlaceholder":296},[2310],{"type":55,"value":299},{"type":49,"tag":271,"props":2312,"children":2313},{"class":273,"line":311},[2314,2319],{"type":49,"tag":271,"props":2315,"children":2316},{"style":2275},[2317],{"type":55,"value":2318},"-",{"type":49,"tag":271,"props":2320,"children":2321},{"style":1451},[2322],{"type":55,"value":2323}," Current average gas: X units\n",{"type":49,"tag":271,"props":2325,"children":2326},{"class":273,"line":320},[2327,2331],{"type":49,"tag":271,"props":2328,"children":2329},{"style":2275},[2330],{"type":55,"value":2318},{"type":49,"tag":271,"props":2332,"children":2333},{"style":1451},[2334],{"type":55,"value":2335}," Optimized average gas: Y units\n",{"type":49,"tag":271,"props":2337,"children":2338},{"class":273,"line":328},[2339,2343],{"type":49,"tag":271,"props":2340,"children":2341},{"style":2275},[2342],{"type":55,"value":2318},{"type":49,"tag":271,"props":2344,"children":2345},{"style":1451},[2346],{"type":55,"value":2347}," Savings: Z% reduction\n",{"type":49,"tag":271,"props":2349,"children":2350},{"class":273,"line":27},[2351],{"type":49,"tag":271,"props":2352,"children":2353},{"emptyLinePlaceholder":296},[2354],{"type":55,"value":299},{"type":49,"tag":271,"props":2356,"children":2357},{"class":273,"line":555},[2358,2362],{"type":49,"tag":271,"props":2359,"children":2360},{"style":2275},[2361],{"type":55,"value":2298},{"type":49,"tag":271,"props":2363,"children":2364},{"style":1435},[2365],{"type":55,"value":2366},"Optimizations Applied\n",{"type":49,"tag":271,"props":2368,"children":2369},{"class":273,"line":564},[2370],{"type":49,"tag":271,"props":2371,"children":2372},{"emptyLinePlaceholder":296},[2373],{"type":55,"value":299},{"type":49,"tag":271,"props":2375,"children":2376},{"class":273,"line":573},[2377,2382],{"type":49,"tag":271,"props":2378,"children":2379},{"style":2275},[2380],{"type":55,"value":2381},"### ",{"type":49,"tag":271,"props":2383,"children":2384},{"style":1435},[2385],{"type":55,"value":2386},"1. Storage Optimization\n",{"type":49,"tag":271,"props":2388,"children":2389},{"class":273,"line":581},[2390],{"type":49,"tag":271,"props":2391,"children":2392},{"emptyLinePlaceholder":296},[2393],{"type":55,"value":299},{"type":49,"tag":271,"props":2395,"children":2396},{"class":273,"line":590},[2397,2401],{"type":49,"tag":271,"props":2398,"children":2399},{"style":2275},[2400],{"type":55,"value":2318},{"type":49,"tag":271,"props":2402,"children":2403},{"style":1451},[2404],{"type":55,"value":2405}," Packed struct fields (saved X bytes)\n",{"type":49,"tag":271,"props":2407,"children":2408},{"class":273,"line":599},[2409,2413],{"type":49,"tag":271,"props":2410,"children":2411},{"style":2275},[2412],{"type":55,"value":2318},{"type":49,"tag":271,"props":2414,"children":2415},{"style":1451},[2416],{"type":55,"value":2417}," Replaced vectors with tables (O(n) → O(1))\n",{"type":49,"tag":271,"props":2419,"children":2420},{"class":273,"line":608},[2421,2425],{"type":49,"tag":271,"props":2422,"children":2423},{"style":2275},[2424],{"type":55,"value":2318},{"type":49,"tag":271,"props":2426,"children":2427},{"style":1451},[2428],{"type":55,"value":2429}," Removed redundant fields\n",{"type":49,"tag":271,"props":2431,"children":2432},{"class":273,"line":616},[2433],{"type":49,"tag":271,"props":2434,"children":2435},{"emptyLinePlaceholder":296},[2436],{"type":55,"value":299},{"type":49,"tag":271,"props":2438,"children":2439},{"class":273,"line":624},[2440,2444],{"type":49,"tag":271,"props":2441,"children":2442},{"style":2275},[2443],{"type":55,"value":2381},{"type":49,"tag":271,"props":2445,"children":2446},{"style":1435},[2447],{"type":55,"value":2448},"2. Computation Optimization\n",{"type":49,"tag":271,"props":2450,"children":2451},{"class":273,"line":23},[2452],{"type":49,"tag":271,"props":2453,"children":2454},{"emptyLinePlaceholder":296},[2455],{"type":55,"value":299},{"type":49,"tag":271,"props":2457,"children":2458},{"class":273,"line":640},[2459,2463],{"type":49,"tag":271,"props":2460,"children":2461},{"style":2275},[2462],{"type":55,"value":2318},{"type":49,"tag":271,"props":2464,"children":2465},{"style":1451},[2466],{"type":55,"value":2467}," Cached price calculations (saved X operations)\n",{"type":49,"tag":271,"props":2469,"children":2470},{"class":273,"line":649},[2471,2475],{"type":49,"tag":271,"props":2472,"children":2473},{"style":2275},[2474],{"type":55,"value":2318},{"type":49,"tag":271,"props":2476,"children":2477},{"style":1451},[2478],{"type":55,"value":2479}," Batched updates (N calls → 1 call)\n",{"type":49,"tag":271,"props":2481,"children":2482},{"class":273,"line":657},[2483,2487],{"type":49,"tag":271,"props":2484,"children":2485},{"style":2275},[2486],{"type":55,"value":2318},{"type":49,"tag":271,"props":2488,"children":2489},{"style":1451},[2490],{"type":55,"value":2491}," Early returns in validation\n",{"type":49,"tag":271,"props":2493,"children":2494},{"class":273,"line":665},[2495],{"type":49,"tag":271,"props":2496,"children":2497},{"emptyLinePlaceholder":296},[2498],{"type":55,"value":299},{"type":49,"tag":271,"props":2500,"children":2501},{"class":273,"line":1015},[2502,2506],{"type":49,"tag":271,"props":2503,"children":2504},{"style":2275},[2505],{"type":55,"value":2381},{"type":49,"tag":271,"props":2507,"children":2508},{"style":1435},[2509],{"type":55,"value":2510},"3. Event Optimization\n",{"type":49,"tag":271,"props":2512,"children":2513},{"class":273,"line":1386},[2514],{"type":49,"tag":271,"props":2515,"children":2516},{"emptyLinePlaceholder":296},[2517],{"type":55,"value":299},{"type":49,"tag":271,"props":2519,"children":2520},{"class":273,"line":1394},[2521,2525],{"type":49,"tag":271,"props":2522,"children":2523},{"style":2275},[2524],{"type":55,"value":2318},{"type":49,"tag":271,"props":2526,"children":2527},{"style":1451},[2528],{"type":55,"value":2529}," Reduced event size from X to Y bytes\n",{"type":49,"tag":271,"props":2531,"children":2533},{"class":273,"line":2532},26,[2534,2538],{"type":49,"tag":271,"props":2535,"children":2536},{"style":2275},[2537],{"type":55,"value":2318},{"type":49,"tag":271,"props":2539,"children":2540},{"style":1451},[2541],{"type":55,"value":2542}," Removed redundant event fields\n",{"type":49,"tag":271,"props":2544,"children":2546},{"class":273,"line":2545},27,[2547],{"type":49,"tag":271,"props":2548,"children":2549},{"emptyLinePlaceholder":296},[2550],{"type":55,"value":299},{"type":49,"tag":271,"props":2552,"children":2554},{"class":273,"line":2553},28,[2555,2559],{"type":49,"tag":271,"props":2556,"children":2557},{"style":2275},[2558],{"type":55,"value":2298},{"type":49,"tag":271,"props":2560,"children":2561},{"style":1435},[2562],{"type":55,"value":2563},"Measurements\n",{"type":49,"tag":271,"props":2565,"children":2567},{"class":273,"line":2566},29,[2568],{"type":49,"tag":271,"props":2569,"children":2570},{"emptyLinePlaceholder":296},[2571],{"type":55,"value":299},{"type":49,"tag":271,"props":2573,"children":2575},{"class":273,"line":2574},30,[2576,2581,2586,2590,2595,2599,2604,2608,2613],{"type":49,"tag":271,"props":2577,"children":2578},{"style":2275},[2579],{"type":55,"value":2580},"|",{"type":49,"tag":271,"props":2582,"children":2583},{"style":1451},[2584],{"type":55,"value":2585}," Function ",{"type":49,"tag":271,"props":2587,"children":2588},{"style":2275},[2589],{"type":55,"value":2580},{"type":49,"tag":271,"props":2591,"children":2592},{"style":1451},[2593],{"type":55,"value":2594}," Before ",{"type":49,"tag":271,"props":2596,"children":2597},{"style":2275},[2598],{"type":55,"value":2580},{"type":49,"tag":271,"props":2600,"children":2601},{"style":1451},[2602],{"type":55,"value":2603}," After  ",{"type":49,"tag":271,"props":2605,"children":2606},{"style":2275},[2607],{"type":55,"value":2580},{"type":49,"tag":271,"props":2609,"children":2610},{"style":1451},[2611],{"type":55,"value":2612}," Savings ",{"type":49,"tag":271,"props":2614,"children":2615},{"style":2275},[2616],{"type":55,"value":2617},"|\n",{"type":49,"tag":271,"props":2619,"children":2621},{"class":273,"line":2620},31,[2622,2626,2631,2636,2641,2645,2649,2653,2658],{"type":49,"tag":271,"props":2623,"children":2624},{"style":2275},[2625],{"type":55,"value":2580},{"type":49,"tag":271,"props":2627,"children":2628},{"style":2275},[2629],{"type":55,"value":2630}," --------",{"type":49,"tag":271,"props":2632,"children":2633},{"style":2275},[2634],{"type":55,"value":2635}," |",{"type":49,"tag":271,"props":2637,"children":2638},{"style":2275},[2639],{"type":55,"value":2640}," ------",{"type":49,"tag":271,"props":2642,"children":2643},{"style":2275},[2644],{"type":55,"value":2635},{"type":49,"tag":271,"props":2646,"children":2647},{"style":2275},[2648],{"type":55,"value":2640},{"type":49,"tag":271,"props":2650,"children":2651},{"style":2275},[2652],{"type":55,"value":2635},{"type":49,"tag":271,"props":2654,"children":2655},{"style":2275},[2656],{"type":55,"value":2657}," -------",{"type":49,"tag":271,"props":2659,"children":2660},{"style":2275},[2661],{"type":55,"value":2662}," |\n",{"type":49,"tag":271,"props":2664,"children":2666},{"class":273,"line":2665},32,[2667,2671,2676,2680,2685,2689,2694,2698,2703],{"type":49,"tag":271,"props":2668,"children":2669},{"style":2275},[2670],{"type":55,"value":2580},{"type":49,"tag":271,"props":2672,"children":2673},{"style":1451},[2674],{"type":55,"value":2675}," mint     ",{"type":49,"tag":271,"props":2677,"children":2678},{"style":2275},[2679],{"type":55,"value":2580},{"type":49,"tag":271,"props":2681,"children":2682},{"style":1451},[2683],{"type":55,"value":2684}," 50,000 ",{"type":49,"tag":271,"props":2686,"children":2687},{"style":2275},[2688],{"type":55,"value":2580},{"type":49,"tag":271,"props":2690,"children":2691},{"style":1451},[2692],{"type":55,"value":2693}," 35,000 ",{"type":49,"tag":271,"props":2695,"children":2696},{"style":2275},[2697],{"type":55,"value":2580},{"type":49,"tag":271,"props":2699,"children":2700},{"style":1451},[2701],{"type":55,"value":2702}," 30%     ",{"type":49,"tag":271,"props":2704,"children":2705},{"style":2275},[2706],{"type":55,"value":2617},{"type":49,"tag":271,"props":2708,"children":2710},{"class":273,"line":2709},33,[2711,2715,2720,2724,2729,2733,2738,2742,2747],{"type":49,"tag":271,"props":2712,"children":2713},{"style":2275},[2714],{"type":55,"value":2580},{"type":49,"tag":271,"props":2716,"children":2717},{"style":1451},[2718],{"type":55,"value":2719}," transfer ",{"type":49,"tag":271,"props":2721,"children":2722},{"style":2275},[2723],{"type":55,"value":2580},{"type":49,"tag":271,"props":2725,"children":2726},{"style":1451},[2727],{"type":55,"value":2728}," 30,000 ",{"type":49,"tag":271,"props":2730,"children":2731},{"style":2275},[2732],{"type":55,"value":2580},{"type":49,"tag":271,"props":2734,"children":2735},{"style":1451},[2736],{"type":55,"value":2737}," 25,000 ",{"type":49,"tag":271,"props":2739,"children":2740},{"style":2275},[2741],{"type":55,"value":2580},{"type":49,"tag":271,"props":2743,"children":2744},{"style":1451},[2745],{"type":55,"value":2746}," 17%     ",{"type":49,"tag":271,"props":2748,"children":2749},{"style":2275},[2750],{"type":55,"value":2617},{"type":49,"tag":271,"props":2752,"children":2754},{"class":273,"line":2753},34,[2755,2759,2764,2768,2773,2777,2782,2786,2791],{"type":49,"tag":271,"props":2756,"children":2757},{"style":2275},[2758],{"type":55,"value":2580},{"type":49,"tag":271,"props":2760,"children":2761},{"style":1451},[2762],{"type":55,"value":2763}," swap     ",{"type":49,"tag":271,"props":2765,"children":2766},{"style":2275},[2767],{"type":55,"value":2580},{"type":49,"tag":271,"props":2769,"children":2770},{"style":1451},[2771],{"type":55,"value":2772}," 80,000 ",{"type":49,"tag":271,"props":2774,"children":2775},{"style":2275},[2776],{"type":55,"value":2580},{"type":49,"tag":271,"props":2778,"children":2779},{"style":1451},[2780],{"type":55,"value":2781}," 60,000 ",{"type":49,"tag":271,"props":2783,"children":2784},{"style":2275},[2785],{"type":55,"value":2580},{"type":49,"tag":271,"props":2787,"children":2788},{"style":1451},[2789],{"type":55,"value":2790}," 25%     ",{"type":49,"tag":271,"props":2792,"children":2793},{"style":2275},[2794],{"type":55,"value":2617},{"type":49,"tag":271,"props":2796,"children":2798},{"class":273,"line":2797},35,[2799],{"type":49,"tag":271,"props":2800,"children":2801},{"emptyLinePlaceholder":296},[2802],{"type":55,"value":299},{"type":49,"tag":271,"props":2804,"children":2806},{"class":273,"line":2805},36,[2807,2811],{"type":49,"tag":271,"props":2808,"children":2809},{"style":2275},[2810],{"type":55,"value":2298},{"type":49,"tag":271,"props":2812,"children":2813},{"style":1435},[2814],{"type":55,"value":2815},"Recommendations\n",{"type":49,"tag":271,"props":2817,"children":2819},{"class":273,"line":2818},37,[2820],{"type":49,"tag":271,"props":2821,"children":2822},{"emptyLinePlaceholder":296},[2823],{"type":55,"value":299},{"type":49,"tag":271,"props":2825,"children":2827},{"class":273,"line":2826},38,[2828,2833],{"type":49,"tag":271,"props":2829,"children":2830},{"style":2275},[2831],{"type":55,"value":2832},"1.",{"type":49,"tag":271,"props":2834,"children":2835},{"style":1451},[2836],{"type":55,"value":2837}," Consider further optimizations for high-frequency functions\n",{"type":49,"tag":271,"props":2839,"children":2841},{"class":273,"line":2840},39,[2842,2847],{"type":49,"tag":271,"props":2843,"children":2844},{"style":2275},[2845],{"type":55,"value":2846},"2.",{"type":49,"tag":271,"props":2848,"children":2849},{"style":1451},[2850],{"type":55,"value":2851}," Monitor mainnet usage patterns\n",{"type":49,"tag":271,"props":2853,"children":2855},{"class":273,"line":2854},40,[2856,2861],{"type":49,"tag":271,"props":2857,"children":2858},{"style":2275},[2859],{"type":55,"value":2860},"3.",{"type":49,"tag":271,"props":2862,"children":2863},{"style":1451},[2864],{"type":55,"value":2865}," Set up gas usage alerts\n",{"type":49,"tag":64,"props":2867,"children":2869},{"id":2868},"integration-notes",[2870],{"type":55,"value":2871},"Integration Notes",{"type":49,"tag":80,"props":2873,"children":2874},{},[2875,2888,2901,2914],{"type":49,"tag":84,"props":2876,"children":2877},{},[2878,2880,2886],{"type":55,"value":2879},"Works with ",{"type":49,"tag":220,"props":2881,"children":2883},{"className":2882},[],[2884],{"type":55,"value":2885},"security-audit",{"type":55,"value":2887}," to ensure optimizations don't compromise security",{"type":49,"tag":84,"props":2889,"children":2890},{},[2891,2893,2899],{"type":55,"value":2892},"Use with ",{"type":49,"tag":220,"props":2894,"children":2896},{"className":2895},[],[2897],{"type":55,"value":2898},"generate-tests",{"type":55,"value":2900}," to verify optimizations maintain correctness",{"type":49,"tag":84,"props":2902,"children":2903},{},[2904,2906,2912],{"type":55,"value":2905},"Apply before ",{"type":49,"tag":220,"props":2907,"children":2909},{"className":2908},[],[2910],{"type":55,"value":2911},"deploy-contracts",{"type":55,"value":2913}," for mainnet deployments",{"type":49,"tag":84,"props":2915,"children":2916},{},[2917,2919,2925],{"type":55,"value":2918},"Reference ",{"type":49,"tag":220,"props":2920,"children":2922},{"className":2921},[],[2923],{"type":55,"value":2924},"STORAGE_OPTIMIZATION.md",{"type":55,"value":2926}," for detailed patterns",{"type":49,"tag":64,"props":2928,"children":2930},{"id":2929},"never-rules",[2931],{"type":55,"value":2932},"NEVER Rules",{"type":49,"tag":80,"props":2934,"children":2935},{},[2936,2941,2946],{"type":49,"tag":84,"props":2937,"children":2938},{},[2939],{"type":55,"value":2940},"❌ NEVER optimize away security checks (access control, input validation)",{"type":49,"tag":84,"props":2942,"children":2943},{},[2944],{"type":55,"value":2945},"❌ NEVER deploy optimized code without re-testing",{"type":49,"tag":84,"props":2947,"children":2948},{},[2949,2951,2957,2959,2965],{"type":55,"value":2950},"❌ NEVER read ",{"type":49,"tag":220,"props":2952,"children":2954},{"className":2953},[],[2955],{"type":55,"value":2956},".env",{"type":55,"value":2958}," or ",{"type":49,"tag":220,"props":2960,"children":2962},{"className":2961},[],[2963],{"type":55,"value":2964},"~\u002F.aptos\u002Fconfig.yaml",{"type":55,"value":2966}," during gas analysis (contain private keys)",{"type":49,"tag":64,"props":2968,"children":2970},{"id":2969},"references",[2971],{"type":55,"value":2972},"References",{"type":49,"tag":80,"props":2974,"children":2975},{},[2976,2989,3000],{"type":49,"tag":84,"props":2977,"children":2978},{},[2979,2981],{"type":55,"value":2980},"Aptos Gas Schedule: ",{"type":49,"tag":2982,"props":2983,"children":2987},"a",{"href":2984,"rel":2985},"https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-core\u002Fblob\u002Fmain\u002Faptos-move\u002Faptos-gas-schedule",[2986],"nofollow",[2988],{"type":55,"value":2984},{"type":49,"tag":84,"props":2990,"children":2991},{},[2992,2994],{"type":55,"value":2993},"Move VM Gas Metering: ",{"type":49,"tag":2982,"props":2995,"children":2998},{"href":2996,"rel":2997},"https:\u002F\u002Fgithub.com\u002Faptos-labs\u002Faptos-core\u002Ftree\u002Fmain\u002Faptos-move\u002Faptos-vm",[2986],[2999],{"type":55,"value":2996},{"type":49,"tag":84,"props":3001,"children":3002},{},[3003],{"type":55,"value":3004},"Gas Optimization Patterns: Check daily-move repository for real examples",{"type":49,"tag":3006,"props":3007,"children":3008},"style",{},[3009],{"type":55,"value":3010},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3012,"total":624},[3013,3019,3038,3051,3064,3078,3092],{"slug":4,"name":4,"fn":5,"description":6,"org":3014,"tags":3015,"stars":23,"repoUrl":24,"updatedAt":25},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3016,3017,3018],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},{"name":21,"slug":22,"type":16},{"slug":3020,"name":3020,"fn":3021,"description":3022,"org":3023,"tags":3024,"stars":23,"repoUrl":24,"updatedAt":3037},"create-aptos-project","scaffold new Aptos dApp projects","Scaffolds new Aptos projects using npx create-aptos-dapp. Supports fullstack (Vite or Next.js) and contract-only templates with network selection and optional API key. Triggers on: 'build app', 'create app', 'make app', 'new app', 'build dApp', 'create dApp', 'new dApp', 'build project', 'new project', 'create project', 'scaffold', 'start project', 'set up project', 'build me a', 'I want to build', 'make me a', 'help me build'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3025,3028,3031,3034],{"name":3026,"slug":3027,"type":16},"Next.js","next-js",{"name":3029,"slug":3030,"type":16},"TypeScript","typescript",{"name":3032,"slug":3033,"type":16},"Vite","vite",{"name":3035,"slug":3036,"type":16},"Web3","web3","2026-07-12T08:07:30.595111",{"slug":2911,"name":2911,"fn":3039,"description":3040,"org":3041,"tags":3042,"stars":23,"repoUrl":24,"updatedAt":3050},"deploy Move contracts to Aptos networks","Safely deploys Move contracts to Aptos networks (devnet, testnet, mainnet) with pre-deployment verification. Triggers on: 'deploy contract', 'publish to testnet', 'deploy to mainnet', 'how to deploy', 'publish module', 'deployment checklist', 'deploy to devnet'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3043,3046,3049],{"name":3044,"slug":3045,"type":16},"Deployment","deployment",{"name":3047,"slug":3048,"type":16},"Engineering","engineering",{"name":21,"slug":22,"type":16},"2026-07-12T08:07:16.798352",{"slug":2898,"name":2898,"fn":3052,"description":3053,"org":3054,"tags":3055,"stars":23,"repoUrl":24,"updatedAt":3063},"generate test suites for Move contracts","Creates comprehensive test suites for Move contracts with 100% coverage requirement. Triggers on: 'generate tests', 'create tests', 'write test suite', 'test this contract', 'how to test', 'add test coverage', 'write unit tests'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3056,3057,3060],{"name":3047,"slug":3048,"type":16},{"name":3058,"slug":3059,"type":16},"QA","qa",{"name":3061,"slug":3062,"type":16},"Testing","testing","2026-07-12T08:07:18.0205",{"slug":3065,"name":3065,"fn":3066,"description":3067,"org":3068,"tags":3069,"stars":23,"repoUrl":24,"updatedAt":3077},"modernize-move","modernize Move V1 contracts to V2","Detects and modernizes outdated Move V1 syntax, patterns, and APIs to Move V2+. Use when upgrading legacy contracts, migrating to modern syntax, or converting old patterns to current best practices. NOT for writing new contracts (use write-contracts) or fixing bugs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3070,3073,3074],{"name":3071,"slug":3072,"type":16},"Code Analysis","code-analysis",{"name":3047,"slug":3048,"type":16},{"name":3075,"slug":3076,"type":16},"Migration","migration","2026-07-12T08:07:10.226223",{"slug":3079,"name":3079,"fn":3080,"description":3081,"org":3082,"tags":3083,"stars":23,"repoUrl":24,"updatedAt":3091},"search-aptos-examples","search Aptos reference implementations","Searches aptos-core and daily-move for reference implementations before writing contracts. Triggers on: 'search examples', 'find example', 'check aptos-core', 'is there an example', 'reference implementation', 'how does aptos implement', 'similar contract', 'daily-move'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3084,3085,3088],{"name":18,"slug":19,"type":16},{"name":3086,"slug":3087,"type":16},"Documentation","documentation",{"name":3089,"slug":3090,"type":16},"Search","search","2026-07-12T08:07:15.382039",{"slug":2885,"name":2885,"fn":3093,"description":3094,"org":3095,"tags":3096,"stars":23,"repoUrl":24,"updatedAt":3105},"audit Move smart contracts for security","Audits Move contracts for security vulnerabilities before deployment using 7-category checklist. Triggers on: 'audit contract', 'security check', 'review security', 'check for vulnerabilities', 'security audit', 'is this secure', 'find security issues'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3097,3100,3101,3104],{"name":3098,"slug":3099,"type":16},"Audit","audit",{"name":3071,"slug":3072,"type":16},{"name":3102,"slug":3103,"type":16},"Security","security",{"name":21,"slug":22,"type":16},"2026-07-12T08:07:11.680215",{"items":3107,"total":1386},[3108,3114,3121,3127,3133,3139,3145,3152,3166,3181,3191,3201],{"slug":4,"name":4,"fn":5,"description":6,"org":3109,"tags":3110,"stars":23,"repoUrl":24,"updatedAt":25},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3111,3112,3113],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},{"name":21,"slug":22,"type":16},{"slug":3020,"name":3020,"fn":3021,"description":3022,"org":3115,"tags":3116,"stars":23,"repoUrl":24,"updatedAt":3037},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3117,3118,3119,3120],{"name":3026,"slug":3027,"type":16},{"name":3029,"slug":3030,"type":16},{"name":3032,"slug":3033,"type":16},{"name":3035,"slug":3036,"type":16},{"slug":2911,"name":2911,"fn":3039,"description":3040,"org":3122,"tags":3123,"stars":23,"repoUrl":24,"updatedAt":3050},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3124,3125,3126],{"name":3044,"slug":3045,"type":16},{"name":3047,"slug":3048,"type":16},{"name":21,"slug":22,"type":16},{"slug":2898,"name":2898,"fn":3052,"description":3053,"org":3128,"tags":3129,"stars":23,"repoUrl":24,"updatedAt":3063},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3130,3131,3132],{"name":3047,"slug":3048,"type":16},{"name":3058,"slug":3059,"type":16},{"name":3061,"slug":3062,"type":16},{"slug":3065,"name":3065,"fn":3066,"description":3067,"org":3134,"tags":3135,"stars":23,"repoUrl":24,"updatedAt":3077},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3136,3137,3138],{"name":3071,"slug":3072,"type":16},{"name":3047,"slug":3048,"type":16},{"name":3075,"slug":3076,"type":16},{"slug":3079,"name":3079,"fn":3080,"description":3081,"org":3140,"tags":3141,"stars":23,"repoUrl":24,"updatedAt":3091},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3142,3143,3144],{"name":18,"slug":19,"type":16},{"name":3086,"slug":3087,"type":16},{"name":3089,"slug":3090,"type":16},{"slug":2885,"name":2885,"fn":3093,"description":3094,"org":3146,"tags":3147,"stars":23,"repoUrl":24,"updatedAt":3105},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3148,3149,3150,3151],{"name":3098,"slug":3099,"type":16},{"name":3071,"slug":3072,"type":16},{"name":3102,"slug":3103,"type":16},{"name":21,"slug":22,"type":16},{"slug":3153,"name":3153,"fn":3154,"description":3155,"org":3156,"tags":3157,"stars":23,"repoUrl":24,"updatedAt":3165},"smoothsend-gasless","sponsor gas fees for Aptos dApps","How to sponsor gas fees for Aptos dApp users using SmoothSend. Paid commercial service: free on testnet, credit-based on mainnet. Covers 3-line wallet adapter integration (transactionSubmitter), Script Composer for fee-in-token stablecoin transfers. Triggers on: 'gasless', 'sponsor gas', 'users pay no APT', 'transactionSubmitter', 'SmoothSend', 'fee payer', 'pay gas for users', 'no gas required'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3158,3161,3164],{"name":3159,"slug":3160,"type":16},"API Development","api-development",{"name":3162,"slug":3163,"type":16},"Payments","payments",{"name":3035,"slug":3036,"type":16},"2026-07-12T08:07:31.843242",{"slug":3167,"name":3167,"fn":3168,"description":3169,"org":3170,"tags":3171,"stars":23,"repoUrl":24,"updatedAt":3180},"ts-sdk-account","manage Aptos accounts with TS SDK","How to create and use Account (signer) in @aptos-labs\u002Fts-sdk. Covers Account.generate(), fromPrivateKey(), fromDerivationPath(), Ed25519 vs SingleKey vs MultiKey vs Keyless, serialization (fromHex\u002FtoHex). Triggers on: 'Account.generate', 'Account.fromPrivateKey', 'Ed25519PrivateKey', 'SDK account', 'mnemonic', 'SingleKeyAccount', 'KeylessAccount'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3172,3175,3176,3179],{"name":3173,"slug":3174,"type":16},"Auth","auth",{"name":18,"slug":19,"type":16},{"name":3177,"slug":3178,"type":16},"SDK","sdk",{"name":3029,"slug":3030,"type":16},"2026-07-12T08:07:29.297415",{"slug":3182,"name":3182,"fn":3183,"description":3184,"org":3185,"tags":3186,"stars":23,"repoUrl":24,"updatedAt":3190},"ts-sdk-address","manage AccountAddress in Aptos TypeScript SDK","How to create and use AccountAddress in @aptos-labs\u002Fts-sdk. Covers address format (AIP-40), from\u002FfromString\u002FfromStrict, special addresses, LONG vs SHORT form, and derived addresses (object, resource, token, user-derived). Triggers on: 'AccountAddress', 'AccountAddress.from', 'AIP-40', 'derived address', 'createObjectAddress', 'createResourceAddress', 'createTokenAddress'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3187,3188,3189],{"name":18,"slug":19,"type":16},{"name":3177,"slug":3178,"type":16},{"name":3029,"slug":3030,"type":16},"2026-07-12T08:07:26.430378",{"slug":3192,"name":3192,"fn":3193,"description":3194,"org":3195,"tags":3196,"stars":23,"repoUrl":24,"updatedAt":3200},"ts-sdk-client","configure Aptos SDK clients","How to create and configure the Aptos client (Aptos, AptosConfig) in @aptos-labs\u002Fts-sdk. Covers Network, fullnode\u002Findexer\u002Ffaucet URLs, singleton pattern, and Bun compatibility. Triggers on: 'Aptos client', 'AptosConfig', 'SDK client', 'client setup', 'new Aptos(', 'Network.TESTNET', 'Network.MAINNET'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3197,3198,3199],{"name":3159,"slug":3160,"type":16},{"name":3177,"slug":3178,"type":16},{"name":3029,"slug":3030,"type":16},"2026-07-12T08:07:21.933342",{"slug":3202,"name":3202,"fn":3203,"description":3204,"org":3205,"tags":3206,"stars":23,"repoUrl":24,"updatedAt":3210},"ts-sdk-transactions","manage Aptos blockchain transactions","How to build, sign, submit, and simulate transactions in @aptos-labs\u002Fts-sdk. Covers build.simple(), signAndSubmitTransaction(), waitForTransaction(), simulate, sponsored (fee payer), and multi-agent. Triggers on: 'build.simple', 'signAndSubmitTransaction', 'transaction.build', 'waitForTransaction', 'signAsFeePayer', 'SDK transaction', 'sponsored transaction', 'multi-agent transaction'.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3207,3208,3209],{"name":3159,"slug":3160,"type":16},{"name":3029,"slug":3030,"type":16},{"name":3035,"slug":3036,"type":16},"2026-07-12T08:07:23.774257"]