aptos-core
Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
Top Related Projects
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
Reference client for NEAR Protocol
:chains: A Framework for Building High Value Public Blockchains :sparkles:
Algorand's official implementation in Go.
Quick Overview
Aptos-core is the official repository for the Aptos blockchain, a Layer 1 blockchain designed for safe and scalable real-world Web3 applications. It focuses on high throughput, low latency, and strong security measures, utilizing the Move programming language for smart contracts.
Pros
- High performance and scalability, capable of handling over 160,000 transactions per second
- Strong focus on security, leveraging the Move language's safety features
- Active development and regular updates from a dedicated team
- Comprehensive documentation and developer resources
Cons
- Relatively new blockchain, still building its ecosystem and user base
- Limited track record compared to more established blockchains
- Learning curve for developers unfamiliar with the Move language
- Potential for centralization concerns due to its validator structure
Code Examples
- Creating a simple Move module:
module 0x1::basic_coin {
struct Coin has key {
value: u64,
}
public fun mint(account: &signer, value: u64) {
move_to(account, Coin { value })
}
public fun balance(account: address): u64 acquires Coin {
borrow_global<Coin>(account).value
}
}
- Interacting with the Aptos blockchain using the TypeScript SDK:
import { AptosClient, AptosAccount, FaucetClient, TokenClient } from "aptos";
const client = new AptosClient("https://fullnode.devnet.aptoslabs.com/v1");
const faucetClient = new FaucetClient("https://faucet.devnet.aptoslabs.com", client);
const account = new AptosAccount();
await faucetClient.fundAccount(account.address(), 100_000_000);
const tokenClient = new TokenClient(client);
const collectionName = "MyCollection";
const tokenName = "MyToken";
await tokenClient.createCollection(
account,
collectionName,
"My first collection",
"https://example.com/collection"
);
await tokenClient.createToken(
account,
collectionName,
tokenName,
"My first token",
1,
"https://example.com/token"
);
- Querying the Aptos blockchain using the REST API:
import requests
NODE_URL = "https://fullnode.devnet.aptoslabs.com/v1"
account_address = "0x1"
response = requests.get(f"{NODE_URL}/accounts/{account_address}")
print(response.json())
# Get transactions for the account
txn_response = requests.get(f"{NODE_URL}/accounts/{account_address}/transactions")
print(txn_response.json())
Getting Started
To start developing on Aptos:
-
Install the Aptos CLI:
curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3
-
Set up a local development environment:
aptos init
-
Create a new Move project:
aptos move init --name my_first_project
-
Compile and test your Move modules:
aptos move compile aptos move test
-
Deploy your module to the Aptos devnet:
aptos move publish --named-addresses my_addr=default
For more detailed instructions and advanced usage, refer to the official Aptos documentation.
Competitor Comparisons
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Pros of Diem
- More established project with longer development history
- Broader community involvement and contributions
- More comprehensive documentation and resources
Cons of Diem
- Development has slowed down significantly
- Less focus on recent blockchain innovations
- Uncertain future due to project pivot and rebranding
Code Comparison
Diem (Move language):
module DiemAccount {
use Std::Signer;
struct DiemAccount has key {
balance: u64,
}
public fun create_account(account: &signer) {
move_to(account, DiemAccount { balance: 0 });
}
}
Aptos (Move language):
module AptosAccount {
use Std::Signer;
struct AptosAccount has key {
balance: u64,
}
public entry fun create_account(account: &signer) {
move_to(account, AptosAccount { balance: 0 });
}
}
Both projects use the Move language, but Aptos has made some modifications and improvements to the original Diem codebase. The code structure is similar, with minor differences in module naming and function visibility. Aptos introduces the entry
keyword for public functions, which is not present in the original Diem implementation.
Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
Pros of Solana
- More established project with a larger community and ecosystem
- Higher transaction throughput and lower fees
- Proven track record in handling high-volume DeFi applications
Cons of Solana
- More complex architecture, potentially harder for developers to understand
- Centralization concerns due to high hardware requirements for validators
- Occasional network outages and stability issues
Code Comparison
Solana (Rust):
let accounts_to_rent_exempt_check: Vec<(&Pubkey, &AccountSharedData)> = owned_accounts
.iter()
.filter_map(|(pubkey, account)| {
if account.rent_epoch() == INITIAL_RENT_EPOCH {
Some((pubkey, account))
} else {
None
}
})
.collect();
Aptos (Move):
public fun transfer<CoinType>(
from: &signer,
to: address,
amount: u64,
) acquires CoinStore {
let coin = withdraw<CoinType>(from, amount);
deposit(to, coin);
}
The code snippets showcase different approaches: Solana uses Rust for its core implementation, focusing on low-level operations, while Aptos uses Move, a custom language designed for secure smart contract development.
Reference client for NEAR Protocol
Pros of nearcore
- More established project with longer history and larger community
- Supports multiple programming languages for smart contract development
- Implements sharding for improved scalability
Cons of nearcore
- Less focus on formal verification compared to Aptos Core
- Potentially more complex architecture due to sharding implementation
- Slower transaction finality compared to Aptos Core's sub-second finality
Code Comparison
nearcore (Rust):
pub fn process_block(
&mut self,
block: &Block,
provenance: &Provenance,
) -> Result<(), Error> {
// Block processing logic
}
Aptos Core (Move):
public fun process_block(block: &Block, ctx: &mut TxContext) {
// Block processing logic
}
Both projects use Rust for their core implementations, but Aptos Core also heavily utilizes the Move language for smart contracts and core functionality. nearcore supports multiple languages for smart contract development, while Aptos Core focuses on Move for its safety and formal verification capabilities.
:chains: A Framework for Building High Value Public Blockchains :sparkles:
Pros of Cosmos SDK
- More mature ecosystem with a larger developer community
- Supports interoperability between multiple blockchains
- Flexible architecture allowing for customizable application-specific blockchains
Cons of Cosmos SDK
- Steeper learning curve due to complex architecture
- Slower transaction finality compared to Aptos Core
- Less focus on scalability for individual chains
Code Comparison
Cosmos SDK (Go):
func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}
Aptos Core (Rust):
pub fn new_test_with_chunk_executor() -> (
Arc<RwLock<ChunkExecutor<MockVM>>>,
Arc<RwLock<MockVM>>,
DbReaderWriter,
) {
let (db, db_rw) = DbReaderWriter::wrap(MockDb::new());
let vm = MockVM::new();
(
Arc::new(RwLock::new(ChunkExecutor::new(db_rw.clone(), Arc::new(vm.clone())))),
Arc::new(RwLock::new(vm)),
db_rw,
)
}
Both repositories focus on blockchain development, but Cosmos SDK provides a more flexible framework for building interconnected blockchains, while Aptos Core emphasizes high-performance and scalability for a single chain. The code snippets showcase the different languages and approaches used in each project.
Algorand's official implementation in Go.
Pros of go-algorand
- More established project with longer history and larger community
- Faster transaction finality (2.5 seconds vs. 10 seconds for Aptos)
- Lower energy consumption due to pure Proof-of-Stake consensus
Cons of go-algorand
- Less flexible smart contract capabilities compared to Aptos' Move language
- Lower theoretical throughput (1,000 TPS vs. Aptos' claimed 160,000 TPS)
- Less focus on parallel execution of transactions
Code Comparison
Algorand (Go):
func (node *AlgorandFullNode) StartNetwork(config config.Local) error {
node.net = network.NewWebsocketNetwork(config.NetAddress, config.NetworkProtocolVersion)
return node.net.Start()
}
Aptos (Rust):
pub fn start_network(&mut self, config: &NetworkConfig) -> Result<()> {
self.network = Some(Network::new(config.clone()));
self.network.as_mut().unwrap().start()
}
Both examples show network initialization, but Aptos uses Rust's Result type for error handling, while Algorand uses Go's explicit error returns. Aptos also employs Rust's Option type for the network field.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Aptos is a layer 1 blockchain bringing a paradigm shift to Web3 through better technology and user experience. Built with Move to create a home for developers building next-gen applications.
Getting Started
- Aptos Foundation
- Aptos Developer Network
- Guide - Integrate with the Aptos Blockchain
- Tutorials
- Follow us on Twitter.
- Join us on the Aptos Discord.
Contributing
You can learn more about contributing to the Aptos project by reading our Contribution Guide and by viewing our Code of Conduct.
Aptos Core is licensed under Apache 2.0.
Top Related Projects
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
Reference client for NEAR Protocol
:chains: A Framework for Building High Value Public Blockchains :sparkles:
Algorand's official implementation in Go.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot