Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/content/docs/build/guides/first-transaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ This tutorial will guide you through creating and submitting your first transact
```

<Aside type="note">
Notice that Alice's balance decreased by more than 1000 octas. The extra amount is the gas fee paid to process the transaction. Behind the scenes, when checking balances, the SDK queries the CoinStore resource for the AptosCoin (`0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>`) and reads the current stored value. This demonstrates how the SDK abstracts away complex blockchain interactions into simple function calls.
Notice that Alice's balance decreased by more than 1000 octas. The extra amount is the gas fee paid to process the transaction. When checking balances, the TypeScript SDK uses `getAccountAPTAmount`, which resolves APT after the Fungible Asset migration and does not rely on the legacy `CoinStore` resource (new accounts may not have it).
</Aside>
</Steps>
</TabItem>
Expand Down Expand Up @@ -847,7 +847,7 @@ This tutorial will guide you through creating and submitting your first transact
```

<Aside type="note">
Notice that Alice's balance decreased by more than 1000 octas. The extra amount is the gas fee paid to process the transaction. Behind the scenes, when checking balances, the SDK queries the CoinStore resource for the AptosCoin (`0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>`) and reads the current stored value.
Notice that Alice's balance decreased by more than 1000 octas. The extra amount is the gas fee paid to process the transaction. When checking balances, the Python SDK's `account_balance` uses the node's balance APIs, which reflect APT after the Fungible Asset migration rather than only the legacy `CoinStore` resource.
</Aside>
</Steps>
</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ const abstractedAccount = new AbstractedAccount({
const coinTransferTransaction = await aptos.transaction.build.simple({
sender: abstractedAccount.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [alice.accountAddress, 100],
},
});
Expand Down Expand Up @@ -595,11 +594,10 @@ In this example, we will create an authenticator that allows users to permit cer
is the same as the abstracted account's address.

```typescript
const coinTransferTransaction = new aptos.transaction.build.simple({
const coinTransferTransaction = await aptos.transaction.build.simple({
sender: abstractedAccount.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [alice.accountAddress, 100],
},
});
Expand Down
21 changes: 15 additions & 6 deletions src/content/docs/build/sdks/ts-sdk/fetch-data-via-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,27 @@ The `Aptos` client can out of the box query both network data from [fullnodes](h

## Using Generic Queries

Some queries are intentionally broad, but this can make inferring the proper return type difficult. To accommodate that, these broad requests like `getAccountResources` allow you to specify what the expected response type should be.
Some queries are intentionally broad, but this can make inferring the proper return type difficult. To accommodate that, broad requests like `getAccountResources` allow you to specify what the expected response type should be when you use `getAccountResource`.
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording here is internally inconsistent: it cites getAccountResources as the “broad request”, but then says you specify the expected type “when you use getAccountResource”. Since the example is getAccountResource<T>(...), consider rephrasing to describe getAccountResource (or show an example for getAccountResources) to avoid confusing readers about which API supports generic typing.

Suggested change
Some queries are intentionally broad, but this can make inferring the proper return type difficult. To accommodate that, broad requests like `getAccountResources` allow you to specify what the expected response type should be when you use `getAccountResource`.
Some queries are intentionally broad, but this can make inferring the proper return type difficult. To accommodate that, broad requests like `getAccountResource` allow you to specify the expected response type by using a generic type parameter.

Copilot uses AI. Check for mistakes.

After the [Fungible Asset migration](/build/smart-contracts/fungible-asset), use [`getAccountAPTAmount`](https://aptos-labs.github.io/aptos-ts-sdk/) for APT balances. New accounts may not publish the legacy `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>` resource, so reading it with `getAccountResource` can return "resource not found".

```typescript filename="fetch-data.ts"
const aptAmount = await aptos.getAccountAPTAmount({
accountAddress: testAccount.accountAddress,
});
```

For other on-chain resources, use `getAccountResource` with a generic type parameter:

```typescript filename="fetch-data.ts"
type Coin = { coin: { value: string } };
type OnChainAccount = { sequence_number: string; authentication_key: string };

const resource = await aptos.getAccountResource<Coin>({
const accountResource = await aptos.getAccountResource<OnChainAccount>({
accountAddress: testAccount.accountAddress,
resourceType: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
resourceType: "0x1::account::Account",
});

// Now you have access to the response type property
const value = resource.coin.value;
const sequenceNumber = accountResource.sequence_number;
```

## Using Move View Functions
Expand Down
26 changes: 10 additions & 16 deletions src/content/docs/build/sdks/ts-sdk/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 100],
},
// Lower default gas fits typical devnet faucet funding (1 APT)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment implies maxGasAmount maps directly to an APT budget, but maxGasAmount is a gas unit cap; the maximum fee is maxGasAmount * gasUnitPrice (in octas). Consider adjusting the wording to avoid suggesting a direct “1 APT” equivalence, or mention the fee formula to prevent misunderstandings.

Suggested change
// Lower default gas fits typical devnet faucet funding (1 APT)
// Gas unit cap suitable for typical devnet faucet funding (for example, 1 APT);
// actual max fee paid is maxGasAmount * gasUnitPrice (in octas)

Copilot uses AI. Check for mistakes.
options: { maxGasAmount: 100_000 },
});
...
```
Expand Down Expand Up @@ -229,8 +231,6 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';

import { Account, Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const APTOS_COIN = "0x1::aptos_coin::AptosCoin";
const COIN_STORE = `0x1::coin::CoinStore<${APTOS_COIN}>`;
const ALICE_INITIAL_BALANCE = 100_000_000;
const BOB_INITIAL_BALANCE = 100;
const TRANSFER_AMOUNT = 100;
Expand Down Expand Up @@ -267,20 +267,17 @@ async function example() {
});
console.log("Alice and Bob's accounts have been funded!");

// Look up the newly funded account's balances
// Look up the newly funded account's balances (uses Fungible Asset balance APIs;
// legacy CoinStore resources may be absent on new accounts)
console.log("\n=== Balances ===\n");
const aliceAccountBalance = await aptos.getAccountResource({
const aliceBalance = await aptos.getAccountAPTAmount({
accountAddress: alice.accountAddress,
resourceType: COIN_STORE,
});
const aliceBalance = Number(aliceAccountBalance.coin.value);
console.log(`Alice's balance is: ${aliceBalance}`);

const bobAccountBalance = await aptos.getAccountResource({
const bobBalance = await aptos.getAccountAPTAmount({
accountAddress: bob.accountAddress,
resourceType: COIN_STORE,
});
const bobBalance = Number(bobAccountBalance.coin.value);
console.log(`Bob's balance is: ${bobBalance}`);

// Send a transaction from Alice's account to Bob's account
Expand All @@ -289,8 +286,9 @@ async function example() {
data: {
// All transactions on Aptos are implemented via smart contracts.
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 100],
functionArguments: [bob.accountAddress, TRANSFER_AMOUNT],
},
options: { maxGasAmount: 100_000 },
});

console.log("\n=== Transfer transaction ===\n");
Expand All @@ -306,18 +304,14 @@ async function example() {
console.log("Transaction hash:", executedTransaction.hash);

console.log("\n=== Balances after transfer ===\n");
const newAliceAccountBalance = await aptos.getAccountResource({
const newAliceBalance = await aptos.getAccountAPTAmount({
accountAddress: alice.accountAddress,
resourceType: COIN_STORE,
});
const newAliceBalance = Number(newAliceAccountBalance.coin.value);
console.log(`Alice's balance is: ${newAliceBalance}`);

const newBobAccountBalance = await aptos.getAccountResource({
const newBobBalance = await aptos.getAccountAPTAmount({
accountAddress: bob.accountAddress,
resourceType: COIN_STORE,
});
const newBobBalance = Number(newBobAccountBalance.coin.value);
console.log(`Bob's balance is: ${newBobBalance}`);

// Bob should have the transfer amount
Expand Down
11 changes: 4 additions & 7 deletions src/content/docs/zh/build/guides/first-transaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
from aptos_sdk.account import Account
from aptos_sdk.client import RestClient
from aptos_sdk.transactions import EntryFunction, TransactionArgument, TransactionPayload
from aptos_sdk.type_tag import TypeTag, StructTag
```
</TabItem>
</Tabs>
Expand Down Expand Up @@ -237,8 +236,7 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
const transaction = await aptos.transaction.build.simple({
sender: alice.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 1_000_000], // 0.01 APT
},
});
Expand Down Expand Up @@ -274,9 +272,9 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
async def transfer_coins(alice, bob):
# 构建交易
payload = EntryFunction.natural(
"0x1::coin",
"0x1::aptos_account",
"transfer",
[TypeTag(StructTag.from_str("0x1::aptos_coin::AptosCoin"))],
[],
[
TransactionArgument(bob.address(), "address"),
TransactionArgument(1_000_000, "u64"), # 0.01 APT
Expand Down Expand Up @@ -388,8 +386,7 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
const transaction = await aptos.transaction.build.simple({
sender: alice.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 1_000_000], // 0.01 APT
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ const abstractedAccount = new AbstractedAccount({
const coinTransferTransaction = await aptos.transaction.build.simple({
sender: abstractedAccount.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [alice.accountAddress, 100],
},
});
Expand Down Expand Up @@ -577,11 +576,10 @@ const abstractedAccount = new AbstractedAccount({
创建抽象账户后,我们可以正常使用它来签署交易.需要注意的是,交易中的 `sender` 字段必须与抽象账户地址一致.

```typescript
const coinTransferTransaction = new aptos.transaction.build.simple({
const coinTransferTransaction = await aptos.transaction.build.simple({
sender: abstractedAccount.accountAddress,
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
function: "0x1::aptos_account::transfer",
functionArguments: [alice.accountAddress, 100],
},
});
Expand Down
21 changes: 15 additions & 6 deletions src/content/docs/zh/build/sdks/ts-sdk/fetch-data-via-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,27 @@ const tokens = await aptos.getAccountOwnedTokens({ accountAddress: "0x123" });

## 使用通用查询

某些查询设计上是宽泛的,但这可能使得推断正确的返回类型变得困难.为了适应这种情况,像 `getAccountResources` 这样的广泛请求允许你指定预期的响应类型.
某些查询设计上是宽泛的,但这可能使得推断正确的返回类型变得困难.为了适应这种情况,像 `getAccountResources` 这样的广泛请求允许你在使用 `getAccountResource` 时指定预期的响应类型.
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence mixes getAccountResources and getAccountResource in a way that’s confusing: it says broad requests like getAccountResources let you specify the expected type “when using getAccountResource”. Since the snippet uses getAccountResource<T>(...), consider rewriting to directly explain getAccountResource’s generic type parameter (or add a separate example for getAccountResources).

Suggested change
某些查询设计上是宽泛的,但这可能使得推断正确的返回类型变得困难.为了适应这种情况,像 `getAccountResources` 这样的广泛请求允许你在使用 `getAccountResource` 时指定预期的响应类型.
某些查询在设计上是宽泛的,但这可能使得推断正确的返回类型变得困难.为了解决这一问题,你可以在调用 `getAccountResource<T>` 时通过泛型类型参数 `T` 明确指定预期的响应类型,从而让 TypeScript 正确推断返回值.

Copilot uses AI. Check for mistakes.

在[同质化资产迁移](/zh/build/smart-contracts/fungible-asset)之后,请使用 [`getAccountAPTAmount`](https://aptos-labs.github.io/aptos-ts-sdk/) 查询 APT 余额.新账户可能不会发布旧版 `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>` 资源,因此用 `getAccountResource` 读取它可能返回「资源未找到」.

```typescript filename="fetch-data.ts"
const aptAmount = await aptos.getAccountAPTAmount({
accountAddress: testAccount.accountAddress,
});
```

对于其他链上资源,可使用带泛型类型参数的 `getAccountResource`:

```typescript filename="fetch-data.ts"
type Coin = { coin: { value: string } };
type OnChainAccount = { sequence_number: string; authentication_key: string };

const resource = await aptos.getAccountResource<Coin>({
const accountResource = await aptos.getAccountResource<OnChainAccount>({
accountAddress: testAccount.accountAddress,
resourceType: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
resourceType: "0x1::account::Account",
});

// 现在你可以访问响应类型属性
const value = resource.coin.value;
const sequenceNumber = accountResource.sequence_number;
```

## 使用 Move 视图函数
Expand Down
28 changes: 11 additions & 17 deletions src/content/docs/zh/build/sdks/ts-sdk/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 100],
},
// 降低默认 gas 上限以适配常见 devnet 水龙头额度(1 APT)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的注释把 maxGasAmount 和「1 APT」直接关联容易误导:maxGasAmount 是 gas 单位上限,最大手续费实际是 maxGasAmount * gasUnitPrice(octas)。建议改写注释,避免让读者误以为 maxGasAmount 直接表示 APT 额度,或补充手续费计算方式。

Suggested change
// 降低默认 gas 上限以适配常见 devnet 水龙头额度(1 APT
// 将默认 gas 上限设为 100_000 个 gas 单位。实际最高手续费为 maxGasAmount * gasUnitPrice(以 octa 计),请根据账户余额(例如 devnet 常见的 1 APT 水龙头额度)调整。

Copilot uses AI. Check for mistakes.
options: { maxGasAmount: 100_000 },
});
...
```
Expand Down Expand Up @@ -225,8 +227,6 @@ import { Aside, Steps, TabItem, Tabs } from '@astrojs/starlight/components';

import { Account, Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const APTOS_COIN = "0x1::aptos_coin::AptosCoin";
const COIN_STORE = `0x1::coin::CoinStore<${APTOS_COIN}>`;
const ALICE_INITIAL_BALANCE = 100_000_000;
const BOB_INITIAL_BALANCE = 100;
const TRANSFER_AMOUNT = 100;
Expand Down Expand Up @@ -263,20 +263,16 @@ async function example() {
});
console.log("Alice 和 Bob 的账户已成功注资!");

// 查询新注资账户的余额
// 查询新注资账户的余额(使用同质化资产余额接口;新账户可能没有旧版 CoinStore 资源)
console.log("\n=== 余额 ===\n");
const aliceAccountBalance = await aptos.getAccountResource({
const aliceBalance = await aptos.getAccountAPTAmount({
accountAddress: alice.accountAddress,
resourceType: COIN_STORE,
});
const aliceBalance = Number(aliceAccountBalance.coin.value);
console.log(`Alice 的余额是: ${aliceBalance}`);

const bobAccountBalance = await aptos.getAccountResource({
const bobBalance = await aptos.getAccountAPTAmount({
accountAddress: bob.accountAddress,
resourceType: COIN_STORE,
});
const bobBalance = Number(bobAccountBalance.coin.value);
console.log(`Bob 的余额是: ${bobBalance}`);

// 从 Alice 账户向 Bob 账户发送交易
Expand All @@ -285,8 +281,9 @@ async function example() {
data: {
// Aptos 上的所有交易都是通过智能合约实现的。
function: "0x1::aptos_account::transfer",
functionArguments: [bob.accountAddress, 100],
functionArguments: [bob.accountAddress, TRANSFER_AMOUNT],
},
options: { maxGasAmount: 100_000 },
});

console.log("\n=== 转账交易 ===\n");
Expand All @@ -299,19 +296,16 @@ async function example() {
const executedTransaction = await aptos.waitForTransaction({
transactionHash: committedTxn.hash,
});
console.log("交易哈希:", executedTransaction.hash); console.log("\n=== 转账后余额 ===\n");
const newAliceAccountBalance = await aptos.getAccountResource({
console.log("交易哈希:", executedTransaction.hash);
console.log("\n=== 转账后余额 ===\n");
const newAliceBalance = await aptos.getAccountAPTAmount({
accountAddress: alice.accountAddress,
resourceType: COIN_STORE,
});
const newAliceBalance = Number(newAliceAccountBalance.coin.value);
console.log(`Alice 的余额是: ${newAliceBalance}`);

const newBobAccountBalance = await aptos.getAccountResource({
const newBobBalance = await aptos.getAccountAPTAmount({
accountAddress: bob.accountAddress,
resourceType: COIN_STORE,
});
const newBobBalance = Number(newBobAccountBalance.coin.value);
console.log(`Bob 的余额是: ${newBobBalance}`);

// Bob 应该收到转账金额
Expand Down
Loading