$npx -y skills add aptos-labs/aptos-agent-skills --skill use-ts-sdkOrchestrates TypeScript SDK integration for Aptos dApps. Routes to granular skills for specific tasks (client setup, accounts, transactions, view functions, types, wallet adapter). Use this skill for fullstack dApp integration or when multiple SDK concerns are involved. Triggers
| 1 | # Use TypeScript SDK (Orchestrator) |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Orchestrates `@aptos-labs/ts-sdk` integration for Aptos dApps. For specific tasks, route to the appropriate granular |
| 6 | skill. For composite tasks (e.g., "build me a fullstack dApp"), follow the workflow below. |
| 7 | |
| 8 | ## Core Rules |
| 9 | |
| 10 | 1. **ALWAYS use `@aptos-labs/ts-sdk`** (the current official SDK, NOT the deprecated `aptos` package) |
| 11 | 2. **NEVER hardcode private keys** in source code or frontend bundles |
| 12 | 3. **NEVER expose private keys** in client-side code or logs |
| 13 | 4. **NEVER store private keys** in environment variables accessible to the browser (use `VITE_` prefix only for public |
| 14 | config) |
| 15 | 5. **ALWAYS load private keys from environment variables** in server-side scripts only, using `process.env` |
| 16 | |
| 17 | ## Important: Boilerplate Template |
| 18 | |
| 19 | If the project was scaffolded with `npx create-aptos-dapp` (boilerplate template), **wallet adapter and SDK setup are |
| 20 | already done.** Before writing new code, check what already exists: |
| 21 | |
| 22 | - `frontend/components/WalletProvider.tsx` — wallet adapter setup with auto-connect |
| 23 | - `frontend/constants.ts` — `NETWORK`, `MODULE_ADDRESS`, `APTOS_API_KEY` from env vars |
| 24 | - `frontend/entry-functions/` — existing entry function patterns (follow these for new ones) |
| 25 | - `frontend/view-functions/` — existing view function patterns (follow these for new ones) |
| 26 | |
| 27 | **Do NOT recreate** wallet provider, client setup, or constants if they already exist. Instead, **follow the existing |
| 28 | patterns** to add new entry/view functions for your Move contracts. |
| 29 | |
| 30 | ## Skill Routing |
| 31 | |
| 32 | Route to the appropriate granular skill based on the task: |
| 33 | |
| 34 | | Task | Skill | |
| 35 | | ---------------------------------------------- | ---------------------------------------------------------- | |
| 36 | | Set up Aptos client / configure network | [ts-sdk-client](../ts-sdk-client/SKILL.md) | |
| 37 | | Create accounts/signers (server-side) | [ts-sdk-account](../ts-sdk-account/SKILL.md) | |
| 38 | | Parse, format, or derive addresses | [ts-sdk-address](../ts-sdk-address/SKILL.md) | |
| 39 | | Build, sign, submit, simulate transactions | [ts-sdk-transactions](../ts-sdk-transactions/SKILL.md) | |
| 40 | | Read on-chain data (view, balances, resources) | [ts-sdk-view-and-query](../ts-sdk-view-and-query/SKILL.md) | |
| 41 | | Map Move types to TypeScript types | [ts-sdk-types](../ts-sdk-types/SKILL.md) | |
| 42 | | Connect wallet in React frontend | [ts-sdk-wallet-adapter](../ts-sdk-wallet-adapter/SKILL.md) | |
| 43 | |
| 44 | ## Fullstack dApp Workflow |
| 45 | |
| 46 | When building a complete frontend integration: |
| 47 | |
| 48 | 1. **Set up client** → read [ts-sdk-client](../ts-sdk-client/SKILL.md) |
| 49 | 2. **Create view function wrappers** → read [ts-sdk-view-and-query](../ts-sdk-view-and-query/SKILL.md) |
| 50 | 3. **Create entry function payloads** → read [ts-sdk-transactions](../ts-sdk-transactions/SKILL.md) |
| 51 | 4. **Wire up wallet connection** → read [ts-sdk-wallet-adapter](../ts-sdk-wallet-adapter/SKILL.md) |
| 52 | 5. **Handle types correctly** → read [ts-sdk-types](../ts-sdk-types/SKILL.md) (as needed) |
| 53 | |
| 54 | ## File Organization Pattern |
| 55 | |
| 56 | ``` |
| 57 | src/ |
| 58 | lib/ |
| 59 | aptos.ts # Singleton Aptos client + MODULE_ADDRESS |
| 60 | view-functions/ |
| 61 | getCount.ts # One file per view function |
| 62 | getListing.ts |
| 63 | entry-functions/ |
| 64 | increment.ts # One file per entry function |
| 65 | createListing.ts |
| 66 | hooks/ |
| 67 | useCounter.ts # React hooks wrapping view functions |
| 68 | useListing.ts |
| 69 | components/ |
| 70 | WalletProvider.tsx # AptosWalletAdapterProvider wrapper |
| 71 | IncrementButton.tsx # Components calling entry functions |
| 72 | ``` |
| 73 | |
| 74 | ## Error Handling Pattern |
| 75 | |
| 76 | ```typescript |
| 77 | async function submitTransaction( |
| 78 | aptos: Aptos, |
| 79 | signer: Account, |
| 80 | payload: InputGenerateTransactionPayloadData |
| 81 | ): Promise<string> { |
| 82 | try { |
| 83 | const transaction = await aptos.transaction.build.simple({ |
| 84 | sender: signer.accountAddress, |
| 85 | data: payload |
| 86 | }); |
| 87 | |
| 88 | const pendingTx = await aptos.signAndSubmitTransaction({ |
| 89 | signer, |
| 90 | transaction |
| 91 | }); |
| 92 | |
| 93 | const committed = await aptos.waitForTransaction({ |
| 94 | transactionHash: pendingTx.hash |
| 95 | }); |
| 96 | |
| 97 | if (!committed.success) { |
| 98 | throw new Error(`Transaction failed: ${committed.vm_status}`); |
| 99 | } |
| 100 | |
| 101 | return pe |