Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 8da8ba8

Browse files
authored
[i18n] zh build/sdks/ts-sdk (#929)
zh build/sdks/ts-sdk
1 parent a84691d commit 8da8ba8

21 files changed

+2809
-24
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "TypeScript SDK"
3+
---
4+
5+
import { RemoteCodeblock, permalinkFetch, Cards, Card } from '@components/index'
6+
7+
export async function getStaticProps() {
8+
return await permalinkFetch([
9+
'https://github.com/aptos-labs/aptos-ts-sdk/blob/bcde1e3af2f09615015c774fb0c2f5206377346e/examples/typescript/simple_transfer.ts#L77-L91'
10+
])
11+
}
12+
13+
# TypeScript SDK
14+
15+
<div className="flex gap-2 mt-6 flex-wrap">
16+
<a target="_blank" href="https://github.com/aptos-labs/aptos-ts-sdk">
17+
![Github Repo Stars](https://img.shields.io/github/stars/aptos-labs/aptos-ts-sdk)
18+
</a>
19+
<a target="_blank" href="https://www.npmjs.com/package/@aptos-labs/ts-sdk">
20+
![NPM Version](https://img.shields.io/npm/v/%40aptos-labs%2Fts-sdk)
21+
</a>
22+
{/* 如果后续需要再添加这些 */}
23+
{/* <a target="_blank" href="https://www.npmjs.com/package/@aptos-labs/ts-sdk">
24+
![Node Version](https://img.shields.io/node/v/%40aptos-labs%2Fts-sdk)
25+
</a> */}
26+
{/* <a target="_blank" href="https://www.npmjs.com/package/@aptos-labs/ts-sdk">
27+
![NPM bundle size](https://img.shields.io/bundlephobia/min/%40aptos-labs/ts-sdk)
28+
</a> */}
29+
<a target="_blank" href="https://aptos-labs.github.io/aptos-ts-sdk/@aptos-labs/ts-sdk-latest">
30+
![Static Badge](https://img.shields.io/badge/SDK_Reference-Docs)
31+
</a>
32+
</div>
33+
34+
TypeScript SDK 允许您在 Aptos 区块链上进行连接、探索和交互。您可以用它来请求数据、发送交易、设置测试环境等!
35+
36+
```bash npm2yarn
37+
npm i @aptos-labs/ts-sdk
38+
```
39+
40+
## 示例
41+
42+
<Cards>
43+
<Card href="./ts-sdk/quickstart">
44+
<Card.Title>快速开始</Card.Title>
45+
<Card.Description>查看快速指南,5分钟内获得可运行的演示</Card.Description>
46+
</Card>
47+
<Card href="https://github.com/aptos-labs/aptos-ts-sdk/tree/main/examples/typescript">
48+
<Card.Title>20+ 示例</Card.Title>
49+
<Card.Description>探索 SDK 仓库中提供的所有 TypeScript 示例</Card.Description>
50+
</Card>
51+
<Card href="https://github.com/aptos-labs/aptos-ts-sdk/tree/main/tests/e2e">
52+
<Card.Title>全面测试</Card.Title>
53+
<Card.Description>查看端到端测试,了解如何使用 SDK 的每个功能</Card.Description>
54+
</Card>
55+
</Cards>
56+
57+
### 10 行代码实现 APT 转账
58+
59+
<RemoteCodeblock
60+
permalink="https://github.com/aptos-labs/aptos-ts-sdk/blob/bcde1e3af2f09615015c774fb0c2f5206377346e/examples/typescript/simple_transfer.ts#L77-L91"
61+
/>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export default {
2+
"---get-started---": {
3+
type: "separator",
4+
title: "Get Started",
5+
},
6+
quickstart: {
7+
title: "Quickstart",
8+
},
9+
"---usage---": {
10+
type: "separator",
11+
title: "Usage",
12+
},
13+
account: {
14+
title: "Accounts",
15+
},
16+
"fetch-data-via-sdk": {
17+
title: "Fetch Data",
18+
},
19+
"building-transactions": {
20+
title: "Transactions",
21+
},
22+
"ts-examples": {
23+
title: "Example Code",
24+
},
25+
"type-safe-contract": {
26+
title: "Surf: TypeScript Type Safety for Move Contracts",
27+
},
28+
// Legacy TS SDK should be at the bottom as it is not supposed to be read unless you already know you need it.
29+
"legacy-ts-sdk": {
30+
title: "Legacy TypeScript SDK (Deprecated)",
31+
},
32+
};
Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
---
2-
主題: "創造和管理帳戶口"
2+
title: "创建和管理账户"
33
---
44

55
import { Callout } from 'nextra/components'
66

7-
# 創造和管理帳戶口
8-
9-
這裡有幾種方法用 TypeScript SDK 去生成Aptos的帳戶。你可以使用:
7+
# 创建和管理账户
108

9+
使用 TypeScript SDK 有几种方式可以生成账户凭证。你可以使用:
1110
- `Account.generate()`
1211
- `Account.fromPrivateKey()`
1312
- `Account.fromDerivationPath()`
1413

15-
`Account.generate()` 是最常使用的方法去生成一個全新的私鑰帳戶。
16-
17-
它默認使用`ED25519`解密私鑰,但您也可以手動指定您喜歡的簽名標準:
14+
`Account.generate()` 是最常用的为新账户创建密钥的方法。
15+
它默认使用 `ED25519` 密钥编码,但你也可以手动指定偏好的签名方案:
1816

1917
```ts
20-
const account = Account.generate(); // defaults to Legacy Ed25519
18+
const account = Account.generate(); // 默认为 Legacy Ed25519
2119
const account = Account.generate({ scheme: SigningSchemeInput.Secp256k1Ecdsa }); // Single Sender Secp256k1
2220
const account = Account.generate({
2321
scheme: SigningSchemeInput.Ed25519,
@@ -26,12 +24,12 @@ const account = Account.generate({
2624
```
2725

2826
<Callout type="info">
29-
根據 [AIP-55](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md) SDK 支援「Legacy」和「Unified」身份驗證.“Legacy”包括“ED25519”和“MultiED25519”,“Unified”包括“SingleSender”和“MultiSender”驗證器
27+
根据 [AIP-55](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md)SDK 支持 `Legacy``Unified` 认证方式。`Legacy` 包含 `ED25519``MultiED25519`,而 `Unified` 包含 `SingleSender``MultiSender` 认证器
3028
</Callout>
3129

32-
當你產生了新的憑證,你 **一定要** 把資金傳入,讓aptos的網路知道它的存在。
30+
生成凭证后,你**必须**为其注资,网络才能识别该账户的存在。
3331

34-
在測試的環境中,這個可以使用以下的命令去領取測試幣完成:
32+
在本地网络/开发网络中,可以通过运行以下命令使用 faucet 完成:
3533

3634
```ts filename="fund.ts"
3735
const transaction = await aptos.fundAccount({
@@ -40,35 +38,63 @@ const transaction = await aptos.fundAccount({
4038
});
4139
```
4240

43-
## 表示帳戶的其他方式
44-
如果你有私鑰, 或同等表示,你可以使用它們去創建 `Account` 物件在使用 TypeScript SDK 時管理這些憑證。
41+
对于测试网络,你可以使用此处的铸币页面[here](/network/faucet)
42+
43+
## 其他表示账户的方式
44+
如果你拥有私钥或等效表示形式,可以使用它们创建 `Account` 对象,在使用 TypeScript SDK 时管理这些凭证。
4545

46-
這裡有一些例子是教你怎麼使用具體的解碼方案:
46+
以下是几个展示如何使用特定编码方案实现的示例。
4747

48-
### 從私鑰生成帳戶
48+
### 从私钥派生账户
4949

50-
SDK 支援使用「fromPrivateKey()」靜態方法從私鑰衍生出帳戶
51-
另外,該方法支援從私鑰和帳戶地址衍生帳戶
52-
此方法使用本地計算,因此適合用於衍生尚未輪換身份驗證金鑰的「帳戶」
50+
SDK 支持使用 `fromPrivateKey()` 静态方法从私钥派生账户
51+
此外,该方法还支持从私钥和账户地址派生账户
52+
该方法使用本地计算,因此用于派生尚未进行认证密钥轮换的 `Account`
5353

5454
```ts
55-
// to derive an account with a legacy Ed25519 key scheme
55+
// 使用 legacy Ed25519 密钥方案派生账户
5656
const privateKey = new Ed25519PrivateKey(privateKeyBytes);
5757
const account = Account.fromPrivateKey({ privateKey });
5858

59-
// to derive an account with a Single Sender Ed25519 key scheme
59+
// 使用 Single Sender Ed25519 密钥方案派生账户
6060
const privateKey = new Ed25519PrivateKey(privateKeyBytes);
6161
const account = Account.fromPrivateKey({ privateKey, legacy: false });
6262

63-
// to derive an account with a Single Sender Secp256k1 key scheme
63+
// 使用 Single Sender Secp256k1 密钥方案派生账户
6464
const privateKey = new Secp256k1PrivateKey(privateKeyBytes);
6565
const account = Account.fromPrivateKey({ privateKey });
6666

67-
// to derive an account with a private key and account address
67+
// 使用私钥和账户地址派生账户
6868
const privateKey = new Ed25519PrivateKey(privateKeyBytes);
6969
const address = AccountAddress.from(address);
7070
const account = Account.fromPrivateKey({ privateKey, address });
7171
```
72-
### 從派生路徑生成帳戶
7372

74-
SDK支援使用「fromDerivationPath()」靜態方法從衍生路徑生成帳戶。
73+
### 从派生路径派生账户
74+
75+
SDK 支持使用 `fromDerivationPath()` 静态方法从派生路径派生账户。
76+
77+
```ts
78+
// 使用传统的 Ed25519 密钥方案派生账户
79+
const { mnemonic, address, path } = wallet;
80+
const account = Account.fromDerivationPath({
81+
path,
82+
mnemonic,
83+
scheme: SigningSchemeInput.Ed25519,
84+
});
85+
86+
// 使用 Single Sender Ed25519 密钥方案派生账户
87+
const { mnemonic, address, path } = wallet;
88+
const account = Account.fromDerivationPath({
89+
path,
90+
mnemonic,
91+
scheme: SigningSchemeInput.Ed25519,
92+
legacy: false,
93+
});// 派生一个使用 Single Sender Secp256k1 密钥方案的账户
94+
const { mnemonic, address, path } = wallet;
95+
const account = Account.fromDerivationPath({
96+
path,
97+
mnemonic,
98+
scheme: SigningSchemeInput.Secp256k1Ecdsa,
99+
});
100+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
"account-abstraction": {
3+
title: "Account Abstraction",
4+
},
5+
"derivable-account-abstraction": {
6+
title: "Derivable Account Abstraction",
7+
},
8+
};

0 commit comments

Comments
 (0)