aptos-framework

$npx mdskill add eric861129/SKILLS_All-in-one/aptos-framework

Provides expert guidance on Aptos Framework core modules for dApp development.

  • Helps developers use account, coin, and fungible_asset modules correctly.
  • Depends on knowledge of 0x1:: and std:: standard library modules.
  • Recommends modules based on user's task like token or object management.
  • Delivers code examples and explanations for Aptos Move development.

SKILL.md

.github/skills/aptos-frameworkView on GitHub ↗
---
name: aptos-framework
description: Expert on Aptos Framework (0x1 standard library) modules including account, coin, fungible_asset, object, timestamp, table, smart_table, event, randomness, aggregator, and resource_account. Essential for all Aptos development.
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
model: sonnet
license: MIT
metadata:
  author: raintree
  version: "1.0"
---

# Aptos Framework Expert

Expert on the Aptos Framework (0x1 address) - the standard library of core modules.

## Triggers

- aptos framework, 0x1::, aptos_framework::
- account module, table, smarttable
- event, timestamp, randomness
- aggregator, resource account

## Framework Architecture

### Core Modules (0x1::)

```
aptos_framework/
├── account.move           - Account management
├── coin.move              - Fungible token standard (v1)
├── fungible_asset.move    - Fungible asset standard (v2)
├── object.move            - Object model primitives
├── timestamp.move         - Block timestamp access
├── table.move             - Key-value storage
├── smart_table.move       - Auto-split table
├── event.move             - Event emission
├── randomness.move        - Secure randomness (VRF)
├── aggregator_v2.move     - Parallel execution
├── resource_account.move  - Deterministic deployment
```

### Standard Library (std::)

```
move-stdlib/
├── vector.move      - Dynamic arrays
├── option.move      - Optional values
├── string.move      - UTF8 strings
├── signer.move      - Signer operations
├── error.move       - Error codes
```

## Key Modules

### account.move

```move
use aptos_framework::account;

// Create account
account::create_account(new_address);

// Get sequence number
account::get_sequence_number(addr);

// Check existence
account::exists_at(addr);

// SignerCapability pattern
let (resource_signer, signer_cap) = account::create_resource_account(deployer, b"SEED");
```

### table.move / smart_table.move

```move
use aptos_framework::table::{Self, Table};

struct Registry has key {
    data: Table<address, UserData>
}

table::add(&mut t, key, value);
table::borrow(&t, key);
table::borrow_mut(&mut t, key);
table::remove(&mut t, key);
table::contains(&t, key);
```

### event.move (V2 - Recommended)

```move
#[event]
struct TransferEvent has drop, store {
    from: address,
    to: address,
    amount: u64,
}

event::emit(TransferEvent { from, to, amount });
```

### timestamp.move

```move
use aptos_framework::timestamp;

timestamp::now_seconds();
timestamp::now_microseconds();
```

### randomness.move

```move
use aptos_framework::randomness;

#[randomness]
public entry fun random_mint(user: &signer) {
    let random_value = randomness::u64_integer();
    let amount = randomness::u64_range(100, 1000);
}
```

### aggregator_v2.move

```move
use aptos_framework::aggregator_v2::{Self, Aggregator};

struct Stats has key {
    total: Aggregator<u64>  // Parallel-safe counter
}

aggregator_v2::create_aggregator(0);
aggregator_v2::add(&mut agg, 1);
aggregator_v2::read(&agg);
```

### resource_account.move

```move
// Deterministic address: hash(creator_address, seed)
let (resource_signer, signer_cap) = account::create_resource_account(deployer, b"SEED");

// Store capability for later use
move_to(&resource_signer, Data { signer_cap });

// Use later
let signer = account::create_signer_with_capability(&signer_cap);
```

## Common Patterns

### Time-Locked Operations

```move
struct TimeLock has key {
    unlock_time: u64,
}

public fun withdraw() acquires TimeLock {
    assert!(timestamp::now_seconds() >= timelock.unlock_time, ERROR_LOCKED);
}
```

### Registry with Table

```move
struct Registry<K: copy + drop, V: store> has key {
    data: Table<K, V>,
    count: u64,
}
```

### Event-Driven State

```move
#[event]
struct StateChanged has drop, store {
    old_state: u8,
    new_state: u8,
    timestamp: u64,
}

event::emit(StateChanged { old_state, new_state, timestamp: timestamp::now_seconds() });
```

## Best Practices

- Use SmartTable for large datasets (100k+ entries)
- Use Event V2 API (simpler, cheaper)
- Use Aggregator for global counters (parallel execution)
- Use resource accounts for protocol addresses
- Check timestamp carefully (validator-set, can drift)
- Use randomness only in entry functions with #[randomness]

More from eric861129/SKILLS_All-in-one

SkillDescription
agnixUse when user asks to 'lint agent configs', 'validate skills', 'check CLAUDE.md', 'validate hooks', 'lint MCP'. Validates agent configuration files against 231 rules across 10+ AI tools.
anthropic-expertExpert on Anthropic Claude API, models, prompt engineering, function calling, vision, and best practices. Triggers on anthropic, claude, api, prompt, function calling, vision, messages api, embeddings
aptos-cliExpert in Aptos CLI for account management, contract deployment, transaction submission, and node operations. Use when using the Aptos CLI to initialize profiles, deploy Move contracts, submit transactions, manage accounts, or operate Aptos nodes.
aptos-coreExpert in Aptos blockchain core architecture: consensus (AptosBFT), execution (Block-STM), and networking. Use when analyzing Aptos protocol design, the Rust codebase, validator operations, or understanding how Block-STM parallel execution works.
aptos-dapp-integrationExpert on building Aptos dApps with frontend integration. Covers wallet connectivity (Petra, Martian, Pontem), wallet adapter patterns, TypeScript SDK, transaction building and submission, account management, and React/Next.js integration.
aptos-gas-optimizationAptos gas optimization expert for Move smart contracts. Covers storage costs, execution efficiency, inline functions, aggregators for parallel execution, Table vs SmartTable vs vector tradeoffs, event optimization, struct packing, and gas profiling tools.
aptos-indexerExpert in Aptos Indexer architecture and GraphQL API for querying blockchain data. Use when querying NFTs, coin balances, or transaction history via GraphQL, designing custom processors, or optimizing data retrieval from the Aptos blockchain.
aptos-move-languageExpert on Move programming language fundamentals including abilities (copy/drop/store/key), generics, phantom types, references, global storage operations (move_to/move_from/borrow_global), signer pattern, visibility modifiers, and advanced type system features.
aptos-move-testingExpert on testing Move smart contracts including unit tests, integration tests, Move Prover formal verification, debugging strategies, test coverage, and CI/CD integration for Aptos development.
aptos-object-modelExpert on Aptos Object Model for composable, transferable on-chain assets. Use when working with ObjectCore, Object wrappers, ConstructorRef, ExtendRef, DeleteRef, TransferRef capabilities, or implementing composable asset patterns on Aptos blockchain.