This skill helps you find relevant examples in official Aptos repositories before writing new contracts. Always search examples first to follow established patterns.
Repositories:
aptos-labs/aptos-core/aptos-move/move-examples/ — 53+ official Move examples demonstrating best practicesaptos-labs/daily-move/snippets/ — 17 curated educational examples covering design patterns, Move 2 features,
composable NFTs, and moreCategorize your contract:
Priority Examples by Category:
token_objects/ - Modern object-based tokens (V2 pattern)mint_nft/ - NFT minting patternsnft_dao/ - NFT-gated governancecollection_manager/ - Collection managementcomposable-nfts/ - NFTs that contain other NFTsmodifying-nfts/ - Mutable NFT metadata patternsparallel-nfts/ - Concurrent NFT mintingliquid-nfts/ - Fractionalized/liquid NFTsWhen to use: Building NFT collections, digital collectibles, tokenized assets
fungible_asset/ - Modern fungible token standardcoin/ - Basic coin implementationmanaged_fungible_asset/ - Controlled fungible assetsfa-lockup-example/ - FA lockup and escrow patternsfractional-token/ - Fractional token ownershipcontrolled-mint/ - Controlled minting with access controlWhen to use: Creating tokens, currencies, reward points
marketplace/ - NFT marketplace patternsswap/ - Simple token swapliquidity_pool/ - AMM pool implementationstaking/ - Staking mechanismsWhen to use: Building DEXs, marketplaces, trading platforms
dao/ - DAO governance patternsvoting/ - Voting mechanismsmultisig/ - Multi-signature accountsWhen to use: Building DAOs, governance systems, voting
hello_blockchain/ - Module structure basicsmessage_board/ - Simple state managementresource_account/ - Resource patterns (legacy - avoid for new code)error-codes/ - Error code conventions and patternsprivate-vs-public/ - Function visibility and accessobjects/ - Object model fundamentalsWhen to use: Learning Move basics, simple contracts
object_playground/ - Object model explorationcapability/ - Capability-based securityupgradeable/ - Upgradeable contractsdesign-patterns/ - Autonomous objects and other design patternsstruct-capabilities/ - Struct-based capability patternsmove-2/ - Move 2 language features and idiomsstorage/ - Storage layout and optimization patternsdata-structures/ - Heap data structure implementationWhen to use: Complex architectures, security patterns
lootbox/ - Randomized loot box mechanicsWhen to use: Building games, randomized rewards, loot systems
What to look for:
Don't copy blindly - adapt:
BuildingSearch ForSourceKey FilesNFT Collectiontoken_objects, mint_nftaptos-coretoken_objects/sources/token.moveFungible Tokenfungible_assetaptos-corefungible_asset/sources/fungible_asset.moveMarketplacemarketplaceaptos-coremarketplace/sources/marketplace.moveDAOdao, votingaptos-coredao/sources/dao.moveToken Swapswap, liquidity_poolaptos-coreswap/sources/swap.moveStakingstakingaptos-corestaking/sources/staking.moveSimple Contracthello_blockchain, message_boardaptos-corehello_blockchain/sources/hello.moveObject Patternsobject_playgroundaptos-coreobject_playground/sources/playground.moveComposable NFTscomposable-nftsdaily-movesnippets/composable-nfts/FA Lockup/Escrowfa-lockup-exampledaily-movesnippets/fa-lockup-example/Design Patternsdesign-patternsdaily-movesnippets/design-patterns/Move 2 Featuresmove-2daily-movesnippets/move-2/Data Structuresdata-structuresdaily-movesnippets/data-structures/Storage Patternsstoragedaily-movesnippets/storage/Loot Box Patternslootboxdaily-movesnippets/lootbox/
text
https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples
Browse online and read source files directly.
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.move
Browse online:
text
https://github.com/aptos-labs/daily-move/tree/main/snippets
Clone locally:
bash
git clone https://github.com/aptos-labs/daily-move.git
cd daily-move/snippets
ls -la
text
https://aptos.dev/build/smart-contracts
Many examples are documented with explanations.
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.
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.
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).
"0x..." placeholdersBefore writing contract code:
Search: Find token_objects example
Review Structure: text
token_objects/
├── sources/
│ ├── collection.move # Collection management
│ ├── token.move # Token operations
│ └── property_map.move # Metadata handling
└── tests/
└── token_tests.move
Identify Key Patterns:
create_collectioncreate_named_tokenPropertyMapTransferRefAdapt to Your Needs:
Reference in Code: move
// Adapted from: aptos-core/move-examples/token_objects
module my_addr::custom_nft {
// ... your implementation
}
Official Examples:
Related Skills:
write-contracts - Apply patterns after searchingsecurity-audit - Verify security of adapted codegenerate-tests - Test adapted patternsRemember: Search examples first. Understand patterns. Adapt securely. Test thoroughly.