search-aptos-examples
Original:🇺🇸 English
Translated
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'.
7installs
Added on
NPX Install
npx skill4agent add iskysun96/aptos-agent-skills search-aptos-examplesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Search Aptos Examples Skill
Overview
This skill helps you find relevant examples in official Aptos repositories before writing new contracts. Always
search examples first to follow established patterns.
Repositories:
- — 53+ official Move examples demonstrating best practices
aptos-labs/aptos-core/aptos-move/move-examples/ - — 17 curated educational examples covering design patterns, Move 2 features, composable NFTs, and more
aptos-labs/daily-move/snippets/
Core Workflow
Step 1: Identify What You're Building
Categorize your contract:
- NFTs/Tokens: NFT collections, digital assets, collectibles
- Fungible Assets: Coins, tokens, currencies
- DeFi: DEXs, AMMs, lending, staking
- Governance: DAOs, voting, proposals
- Marketplace: Trading, escrow, auctions
- Gaming: Items, characters, game logic
- Infrastructure: Registries, configs, utilities
Step 2: Search Relevant Examples
Priority Examples by Category:
NFTs & Token Objects
- - Modern object-based tokens (V2 pattern)
token_objects/ - - NFT minting patterns
mint_nft/ - - NFT-gated governance
nft_dao/ - - Collection management
collection_manager/ - (daily-move) - NFTs that contain other NFTs
composable-nfts/ - (daily-move) - Mutable NFT metadata patterns
modifying-nfts/ - (daily-move) - Concurrent NFT minting
parallel-nfts/ - (daily-move) - Fractionalized/liquid NFTs
liquid-nfts/
When to use: Building NFT collections, digital collectibles, tokenized assets
Fungible Assets
- - Modern fungible token standard
fungible_asset/ - - Basic coin implementation
coin/ - - Controlled fungible assets
managed_fungible_asset/ - (daily-move) - FA lockup and escrow patterns
fa-lockup-example/ - (daily-move) - Fractional token ownership
fractional-token/ - (daily-move) - Controlled minting with access control
controlled-mint/
When to use: Creating tokens, currencies, reward points
DeFi & Trading
- - NFT marketplace patterns
marketplace/ - - Simple token swap
swap/ - - AMM pool implementation
liquidity_pool/ - - Staking mechanisms
staking/
When to use: Building DEXs, marketplaces, trading platforms
Governance & DAOs
- - DAO governance patterns
dao/ - - Voting mechanisms
voting/ - - Multi-signature accounts
multisig/
When to use: Building DAOs, governance systems, voting
Basic Patterns
- - Module structure basics
hello_blockchain/ - - Simple state management
message_board/ - - Resource patterns (legacy - avoid for new code)
resource_account/ - (daily-move) - Error code conventions and patterns
error-codes/ - (daily-move) - Function visibility and access
private-vs-public/ - (daily-move) - Object model fundamentals
objects/
When to use: Learning Move basics, simple contracts
Advanced Patterns
- - Object model exploration
object_playground/ - - Capability-based security
capability/ - - Upgradeable contracts
upgradeable/ - (daily-move) - Autonomous objects and other design patterns
design-patterns/ - (daily-move) - Struct-based capability patterns
struct-capabilities/ - (daily-move) - Move 2 language features and idioms
move-2/ - (daily-move) - Storage layout and optimization patterns
storage/ - (daily-move) - Heap data structure implementation
data-structures/
When to use: Complex architectures, security patterns
Gaming
- (daily-move) - Randomized loot box mechanics
lootbox/
When to use: Building games, randomized rewards, loot systems
Step 3: Review Example Code
What to look for:
-
Module Structure:
- How are imports organized?
- What structs are defined?
- How are error codes structured?
-
Object Creation:
- How are objects created?
- Which refs are generated?
- How is ownership managed?
-
Access Control:
- How is signer authority verified?
- How is object ownership checked?
- What roles/permissions exist?
-
Operations:
- How are transfers handled?
- How are updates secured?
- What validations are performed?
-
Testing:
- What test patterns are used?
- How is coverage achieved?
Step 4: Adapt Patterns to Your Use Case
Don't copy blindly - adapt:
- Understand the pattern: Why is it structured this way?
- Identify core concepts: What security checks are critical?
- Adapt to your needs: Modify for your specific requirements
- Maintain security: Keep all security checks intact
- Test thoroughly: Ensure 100% coverage
Example Discovery Table
| Building | Search For | Source | Key Files |
|---|---|---|---|
| NFT Collection | | aptos-core | |
| Fungible Token | | aptos-core | |
| Marketplace | | aptos-core | |
| DAO | | aptos-core | |
| Token Swap | | aptos-core | |
| Staking | | aptos-core | |
| Simple Contract | | aptos-core | |
| Object Patterns | | aptos-core | |
| Composable NFTs | | daily-move | |
| FA Lockup/Escrow | | daily-move | |
| Design Patterns | | daily-move | |
| Move 2 Features | | daily-move | |
| Data Structures | | daily-move | |
| Storage Patterns | | daily-move | |
| Loot Box Patterns | | daily-move | |
How to Access Examples
Option 1: GitHub Web Interface
https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examplesBrowse online and read source files directly.
Option 2: Clone Repository (Recommended)
bash
# Clone Aptos core
git clone https://github.com/aptos-labs/aptos-core.git
# Navigate to examples
cd aptos-core/aptos-move/move-examples
# List all examples
ls -la
# View specific example
cd token_objects
cat sources/token.moveOption 3: daily-move Repository
Browse online:
https://github.com/aptos-labs/daily-move/tree/main/snippetsClone locally:
bash
git clone https://github.com/aptos-labs/daily-move.git
cd daily-move/snippets
ls -laOption 4: Search Aptos Documentation
https://aptos.dev/build/smart-contractsMany examples are documented with explanations.
Common Patterns from Examples
Pattern 1: Object Creation (from token_objects)
move
// From: token_objects/sources/token.move
public entry fun create_token(
creator: &signer,
collection_name: String,
description: String,
name: String,
uri: String,
) {
let constructor_ref = token::create_named_token(
creator,
collection_name,
description,
name,
option::none(),
uri,
);
// ... additional setup
}Takeaway: Use named tokens for collections, create_object for unique items.
Pattern 2: Access Control (from dao)
move
// From: dao/sources/dao.move
public entry fun execute_proposal(
proposer: &signer,
proposal_id: u64
) acquires DAO, Proposal {
let dao = borrow_global_mut<DAO>(@dao_addr);
let proposal = vector::borrow_mut(&mut dao.proposals, proposal_id);
// Verify proposal passed
assert!(proposal.votes_for > proposal.votes_against, E_PROPOSAL_NOT_PASSED);
// Execute actions
// ...
}Takeaway: Verify state conditions before executing critical operations.
Pattern 3: Transfer Control (from fungible_asset)
move
// From: fungible_asset/sources/fungible_asset.move
public fun transfer<T: key>(
from: &signer,
to: address,
amount: u64
) acquires FungibleStore {
// Verify sender has sufficient balance
let from_store = borrow_global_mut<FungibleStore<T>>(signer::address_of(from));
assert!(from_store.balance >= amount, E_INSUFFICIENT_BALANCE);
// Deduct from sender
from_store.balance = from_store.balance - amount;
// Add to recipient
let to_store = borrow_global_mut<FungibleStore<T>>(to);
to_store.balance = to_store.balance + amount;
}Takeaway: Check-effects-interactions pattern (verify, deduct, add).
ALWAYS Rules
- ✅ ALWAYS search examples before writing new contracts
- ✅ ALWAYS check both aptos-core (canonical) and daily-move (educational) repositories
- ✅ ALWAYS understand patterns before copying
- ✅ ALWAYS adapt patterns to your use case
- ✅ ALWAYS maintain security checks from examples
- ✅ ALWAYS reference which example you adapted from
- ✅ ALWAYS test adapted code thoroughly
NEVER Rules
- ❌ NEVER copy code without understanding it
- ❌ NEVER skip security checks from examples
- ❌ NEVER use deprecated patterns (resource accounts, address-based)
- ❌ NEVER assume examples are always up-to-date (verify against docs)
- ❌ NEVER mix V1 and V2 patterns
- ❌ NEVER include real private keys or credentials when adapting examples — use placeholders
"0x..."
Search Checklist
Before writing contract code:
- Identified category (NFT, DeFi, DAO, etc.)
- Found 2-3 relevant examples in aptos-core
- Checked daily-move snippets for educational examples
- Reviewed module structure
- Identified security patterns
- Understood object creation patterns
- Noted access control mechanisms
- Checked test patterns
- Ready to adapt to my use case
Example Adaptation Workflow
Step-by-Step: Building NFT Collection
-
Search: Findexample
token_objects -
Review Structure:
token_objects/ ├── sources/ │ ├── collection.move # Collection management │ ├── token.move # Token operations │ └── property_map.move # Metadata handling └── tests/ └── token_tests.move -
Identify Key Patterns:
- Collection creation with
create_collection - Token minting with
create_named_token - Metadata storage using
PropertyMap - Transfer control with
TransferRef
- Collection creation with
-
Adapt to Your Needs:
- Keep object creation pattern
- Keep security checks
- Add your custom fields
- Add your business logic
- Write comprehensive tests
-
Reference in Code:move
// Adapted from: aptos-core/move-examples/token_objects module my_addr::custom_nft { // ... your implementation }
References
Official Examples:
- aptos-core: https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples
- daily-move: https://github.com/aptos-labs/daily-move/tree/main/snippets
- Documentation: https://aptos.dev/build/smart-contracts
Related Skills:
- - Apply patterns after searching
write-contracts - - Verify security of adapted code
security-audit - - Test adapted patterns
generate-tests
Remember: Search examples first. Understand patterns. Adapt securely. Test thoroughly.