📦 Ts Sdk Types — TS SDK 类型

v1.0.0

迁移至 @aptos-labs/ts-sdk 的 TypeScript 类型映射:u64/u128/u256 为 bigint,address 为 string,TypeTag、functionArguments 与 typeArguments。触发条件:...

0· 115·0 当前·0 累计
iskysun96 头像by @iskysun96·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/19
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
这是一个仅提供指令的技能,为 @aptos-labs/ts-sdk 提供 TypeScript 类型映射指导,其声明的行为和要求在内部与该目的一致。
评估建议
This skill is a documentation-style guide for using TypeScript types with the Aptos SDK and appears coherent and low-risk. If you plan to use the examples, make sure your project actually has @aptos-labs/ts-sdk installed and that your TypeScript target/environment supports BigInt (and that you handle JSON-returned large integers as strings before converting to BigInt). No credentials or installs are requested by this skill.
详细分析 ▾
用途与能力
Name, description, and the SKILL.md all focus on Move ↔ TypeScript type mapping for @aptos-labs/ts-sdk. There are no requested binaries, env vars, or other resources that don't belong to a documentation/guide skill.
指令范围
The instructions are narrowly scoped to mapping types (bigint for u128/u256, address as string, use of typeArguments/TypeTag, etc.). They do not ask the agent to read unrelated files, access credentials, or transmit data to external endpoints. Imports shown (e.g., TypeTag) are appropriate examples for using the SDK.
安装机制
No install spec and no code files — this is instruction-only documentation, so nothing is written to disk or fetched during install.
凭证需求
The skill requests no environment variables, credentials, or config paths. Its guidance references the @aptos-labs/ts-sdk package, which is appropriate for the stated purpose.
持久化与权限
always is false and there is no indication this skill requests persistent privileges or modifies other skills or system configuration.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/19

ts-sdk-types 技能首发:使用 @aptos-labs/ts-sdk 将 Move 类型映射到 TypeScript 的清晰指南。 - 文档化类型映射:u64/u128/u256 → bigint,address → string,带 typeArguments 的泛型函数,以及 functionArguments 匹配。 - 说明如何处理 TypeTag、视图返回类型及 Move ↔ TypeScript 转换中的常见陷阱。 - 提供简洁表格与示例,覆盖所有常用 Move 类型到对应 TypeScript 表示的映射。 - 强调最佳实践与需避免的误用(如绝不用 number 表示 u128/u256)。 - 给出相关 SDK 模块及关联技能的引用。

无害

安装命令

点击复制
官方npx clawhub@latest install ts-sdk-types
镜像加速npx clawhub@latest install ts-sdk-types --registry https://cn.longxiaskill.com

技能文档

Move → TypeScript(速览)

| Move 类型 | TypeScript 类型 | 示例 | | ------------------- | -------------------------- | ---------------------------------------------------- | | u8, u16, u32 | number | 255, 65535 | | u64 | number \| bigint | 大值优先 bigint | | u128, u256 | bigint | BigInt("340282366920938463463374607431768211455") | | i8..i64 (Move 2.3+) | number \| bigint | i64 大值用 bigint | | i128, i256 | bigint | BigInt("-...") | | bool | boolean | true | | address | string | "0x1" | | signer | — | TS 不传入;signer 即交易发送者 | | vector | Uint8Array \| string (hex) | new Uint8Array([1,2,3]) 或 hex | | vector | T[] | [1, 2, 3] | | String | string | "hello" | | Object | string (对象地址) | objectAddress.toString() | | Option | T \| null | 值或 null |

---

functionArguments

顺序与类型须与 Move entry/view 函数参数一致: ``typescript // Move: public fun transfer(to: address, amount: u64) await aptos.transaction.build.simple({ sender: account.accountAddress, data: { function: "0x1::coin::transfer", typeArguments: ["0x1::aptos_coin::AptosCoin"], functionArguments: [ "0xrecipient...", // address 用 string 1000n // u64 用 bigint(小值可用 number) ] } }); `

---

typeArguments

泛型 Move 函数传完整类型字符串(
address::module::StructName): `typescript // Move: balance(addr): u64 typeArguments: ["0x1::aptos_coin::AptosCoin"];

// Move: transfer(to, amount) typeArguments: ["0x1::aptos_coin::AptosCoin"]; `

---

View 返回类型

`typescript const result = await aptos.view({ payload: { function: "0x1::coin::balance", typeArguments: ["0x1::aptos_coin::AptosCoin"], functionArguments: [accountAddress] } }); // result 为数组;u128 常以 string 形式出现在 JSON const balance = BigInt(result[0] as string); `

---

TypeTag(进阶)

程序化构造 payload 或解析类型字符串时:
`typescript import { TypeTag } from "@aptos-labs/ts-sdk"; import { parseTypeTag } from "@aptos-labs/ts-sdk";

const tag = parseTypeTag("0x1::aptos_coin::AptosCoin"); ` 简单场景用 typeArguments 字符串数组;SDK API 要求时用 TypeTag。

---

Object / 资源地址入参

对象地址按 string 传入(AIP-40 长或短格式): `typescript functionArguments: [ nftObjectAddress.toString(), // 或 "0x..." price ]; ``

---

常见错误

数据来源ClawHub ↗ · 中文优化:龙虾技能库