Orchestrates @aptos-labs/ts-sdk integration for Aptos dApps. For specific tasks, route to the appropriate granular
skill. For composite tasks (e.g., "build me a fullstack dApp"), follow the workflow below.
@aptos-labs/ts-sdk (the current official SDK, NOT the deprecated aptos package)VITE_ prefix only for public
config)process.envIf the project was scaffolded with npx create-aptos-dapp (boilerplate template), wallet adapter and SDK setup are
already done. Before writing new code, check what already exists:
frontend/components/WalletProvider.tsx — wallet adapter setup with auto-connectfrontend/constants.ts — NETWORK, MODULE_ADDRESS, APTOS_API_KEY from env varsfrontend/entry-functions/ — existing entry function patterns (follow these for new ones)frontend/view-functions/ — existing view function patterns (follow these for new ones)Do NOT recreate wallet provider, client setup, or constants if they already exist. Instead, follow the existing patterns to add new entry/view functions for your Move contracts.
Route to the appropriate granular skill based on the task:
TaskSkillSet up Aptos client / configure networkts-sdk-clientCreate accounts/signers (server-side)ts-sdk-accountParse, format, or derive addressests-sdk-addressBuild, sign, submit, simulate transactionsts-sdk-transactionsRead on-chain data (view, balances, resources)ts-sdk-view-and-queryMap Move types to TypeScript typests-sdk-typesConnect wallet in React frontendts-sdk-wallet-adapter
When building a complete frontend integration:
text
src/
lib/
aptos.ts # Singleton Aptos client + MODULE_ADDRESS
view-functions/
getCount.ts # One file per view function
getListing.ts
entry-functions/
increment.ts # One file per entry function
createListing.ts
hooks/
useCounter.ts # React hooks wrapping view functions
useListing.ts
components/
WalletProvider.tsx # AptosWalletAdapterProvider wrapper
IncrementButton.tsx # Components calling entry functions
typescript
async function submitTransaction(
aptos: Aptos,
signer: Account,
payload: InputGenerateTransactionPayloadData
): Promise<string> {
try {
const transaction = await aptos.transaction.build.simple({
sender: signer.accountAddress,
data: payload
});
const pendingTx = await aptos.signAndSubmitTransaction({
signer,
transaction
});
const committed = await aptos.waitForTransaction({
transactionHash: pendingTx.hash
});
if (!committed.success) {
throw new Error(`Transaction failed: ${committed.vm_status}`);
}
return pendingTx.hash;
} catch (error) {
if (error instanceof Error) {
if (error.message.includes("RESOURCE_NOT_FOUND")) {
throw new Error("Resource does not exist at the specified address");
}
if (error.message.includes("MODULE_NOT_FOUND")) {
throw new Error("Contract is not deployed at the specified address");
}
if (error.message.includes("ABORTED")) {
const match = error.message.match(/code: (\d+)/);
const code = match ? match[1] : "unknown";
throw new Error(`Contract error (code ${code})`);
}
}
throw error;
}
}
ScenarioCheckActionResource not founderror.message.includes("RESOURCE_NOT_FOUND")Return default value or nullModule not deployederror.message.includes("MODULE_NOT_FOUND")Show "contract not deployed" messageFunction not founderror.message.includes("FUNCTION_NOT_FOUND")Check function name and module addressMove aborterror.message.includes("ABORTED")Parse abort code, map to user-friendly errorOut of gaserror.message.includes("OUT_OF_GAS")Increase maxGasAmount and retrySequence number errorerror.message.includes("SEQUENCE_NUMBER")Retry after fetching fresh sequence numberNetwork timeouterror.message.includes("timeout")Retry with exponential backoffAccount does not existerror.message.includes("ACCOUNT_NOT_FOUND")Fund account or prompt user to create oneInsufficient balanceerror.message.includes("INSUFFICIENT_BALANCE")Show balance and required amountUser rejected in walletWallet-specific rejection errorShow "transaction cancelled" message
aptos npm package — use @aptos-labs/ts-sdkwaitForTransaction after submitting — transaction may not be committed yetVITE_MODULE_ADDRESS)Aptos client instances — create one singleton and share itAccount.generate() in frontend code for real users — use wallet adapterscriptComposer — removed in v6.0; use separate transactions insteadgetAccountCoinAmount or getAccountAPTAmount — deprecated; use getBalance()Ed25519 and Secp256k1 private keys now use an AIP-80 prefixed format when serialized with toString():
typescript
const key = new Ed25519PrivateKey("0x...");
key.toString(); // Returns AIP-80 prefixed format, NOT raw hex
typescript
await aptos.transferFungibleAssetBetweenStores({
sender: account,
fungibleAssetMetadataAddress: metadataAddr,
senderStoreAddress: fromStore,
recipientStoreAddress: toStore,
amount: 1000n
});
typescript
// Check if AA is enabled for an account
const isEnabled = await aptos.abstraction.isAccountAbstractionEnabled({
accountAddress: "0x...",
authenticationFunction: `${MODULE_ADDRESS}::auth::authenticate`
});
// Enable AA on an account
const enableTxn = await aptos.abstraction.enableAccountAbstractionTransaction({
accountAddress: account.accountAddress,
authenticationFunction: `${MODULE_ADDRESS}::auth::authenticate`
});
// Use AbstractedAccount for signing with custom auth logic
import { AbstractedAccount } from "@aptos-labs/ts-sdk";
Pattern Documentation:
Official Documentation:
Granular Skills:
Related Skills:
write-contracts — Write the Move contracts that this SDK interacts withdeploy-contracts — Deploy contracts before calling them from TypeScript