← Protocols
Aptos
01Description

Aptos is a Move-based L1 with a resource-oriented account model and Block-STM parallel execution. `@aptos-labs/ts-sdk` is the canonical TS SDK for transaction building, BCS serialization, signing, and indexer queries; `@aptos-labs/wallet-adapter-react` provides wallet connection for Petra, Pontem, Martian, and Aptos Connect.

02Best for
  • 01Aptos dapps and Move smart contracts
  • 02resource-model token / NFT (Aptos Digital Assets) apps
  • 03Petra / Aptos Connect wallet auth
  • 04keyless / OIDC-based onboarding
  • 05high-throughput parallel transactions
03Install
  • pnpm add @aptos-labs/ts-sdk @aptos-labs/wallet-adapter-react
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_APTOS_NETWORKClientNetwork — `mainnet`, `testnet`, `devnet`, or `local` (used by `Network` enum).
NEXT_PUBLIC_APTOS_FULLNODE_URLClientOptional fullnode REST URL override (e.g. https://fullnode.mainnet.aptoslabs.com/v1).
APTOS_API_KEYServerAptos Labs API key for the indexer / fullnode (Aptos Build) to lift rate limits.
05Prompt snippet
Use `@aptos-labs/ts-sdk`. Instantiate a client with `const aptos = new Aptos(new AptosConfig({ network: Network.MAINNET, clientConfig: { API_KEY: process.env.APTOS_API_KEY } }))`. Build transactions via `aptos.transaction.build.simple({ sender, data: { function: '0x1::aptos_account::transfer', functionArguments: [recipient, amount] } })`, then sign with `aptos.transaction.sign({ signer, transaction })` and submit through `aptos.transaction.submit.simple({ transaction, senderAuthenticator })`. For wallet UX wrap the React tree in `<AptosWalletAdapterProvider>` and use `useWallet()` (`account`, `signAndSubmitTransaction`). Read on-chain resources with `aptos.getAccountResource({ accountAddress, resourceType: '0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>' })` and use the GraphQL indexer (`aptos.queryIndexer`) for token/NFT queries. Keyless accounts derive addresses from a Google/Apple JWT + ephemeral key pair.
06Gotchas
  • Aptos uses a resource model: state lives in typed Move resources stored under each account address (e.g. `0x1::coin::CoinStore<T>`). You cannot transfer a resource type unless the recipient has registered/initialized it — call the appropriate `register` first or use `0x1::aptos_account::transfer` which auto-creates the store.
  • Transaction payloads are BCS-serialized — use the SDK's typed builders (`functionArguments`, `MoveString`, `MoveVector`) rather than ad-hoc objects; mismatched argument types fail at the VM with `INVALID_ARGUMENT` and no useful trace.
  • Gas is paid in APT (Octas, 10^8 per APT). Each tx specifies `max_gas_amount` and `gas_unit_price`; underestimating either causes `OUT_OF_GAS` and the tx still consumes gas up to the limit.
  • Sequence numbers are strict per-account — bursts of transactions must be submitted in order and the client must call `aptos.getAccountInfo` to refresh the sequence number after each batch, or use `simple` builders that auto-fetch.
  • Finality: Aptos commits in ~1s but the indexer can lag the fullnode by several seconds — write paths read from the fullnode (`getAccountResource`), aggregate read paths use the GraphQL indexer.
  • Move modules can be upgraded under `compatible` policy only if storage layout doesn't break; once published as `immutable` they can never change. Choose carefully at deploy time.
07Alternatives