Ts Sdk Address

v1.0.0

How to create and use AccountAddress in @aptos-labs/ts-sdk. Covers address format (AIP-40), from/fromString/fromStrict, special addresses, LONG vs SHORT form...

0· 152·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for iskysun96/ts-sdk-address.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Ts Sdk Address" (iskysun96/ts-sdk-address) from ClawHub.
Skill page: https://clawhub.ai/iskysun96/ts-sdk-address
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install ts-sdk-address

ClawHub CLI

Package manager switcher

npx clawhub@latest install ts-sdk-address
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name, description, and SKILL.md content all focus on AccountAddress handling (AIP-40, parsing, formatting, derived addresses). There are no unrelated environment variables, binaries, or config requirements.
Instruction Scope
SKILL.md contains only documentation and code examples (imports from @aptos-labs/ts-sdk) and does not instruct the agent to read arbitrary files, environment variables, or transmit data to external endpoints beyond a referenced AIP-40 link. It stays within the stated documentation scope.
Install Mechanism
No install spec or code files are present. Instruction-only skills are lower risk because they do not write or execute new code on disk.
Credentials
The skill declares no required environment variables, secrets, or config paths. Example code uses imports but that does not imply any credential access.
Persistence & Privilege
Skill is not always-enabled and uses standard invocation defaults. It does not request persistent system-level privileges or modify other skills' configurations.
Assessment
This skill is a documentation-only helper for Aptos AccountAddress usage and appears coherent and low-risk. Before installing or enabling it, consider: 1) The SKILL.md claims author 'aptos-labs' but source/homepage are unknown — if provenance matters, verify the author or prefer an official Aptos source. 2) The examples import @aptos-labs/ts-sdk; if the agent or you attempt to run the examples, ensure you trust and have the library installed from the official registry. 3) Never paste private keys or secrets into examples — addresses are public data, but avoid using real private material when testing. 4) If you have an environment policy that forbids autonomous code execution or network installs, ensure the agent cannot auto-install or run the sample code. Overall this skill is internally consistent with its stated purpose.

Like a lobster shell, security has layers — review code before you run it.

latestvk97as65a7dykjhcn82yznm8zxn835xv4
152downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

TypeScript SDK: AccountAddress

Purpose

Guide correct creation, parsing, and formatting of account addresses in @aptos-labs/ts-sdk. Addresses are 32-byte values; string format follows AIP-40.

ALWAYS

  1. Use AccountAddress.from() for flexible input – accepts string (with or without 0x), Uint8Array, or existing AccountAddress.
  2. Use addresses as AccountAddress or string in API – SDK accepts AccountAddressInput (string or AccountAddress) in most APIs.
  3. Use AccountAddress.fromStringStrict() / AccountAddress.fromStrict() when you need AIP-40 strict: LONG (0x + 64 hex chars) or SHORT only for special (0x0–0xf).
  4. Use derived address helpers from the SDK for object/resource/token addresses – do not hand-roll hashing.

NEVER

  1. Do not use raw strings for comparison – use addr.equals(other) or normalize with AccountAddress.from().
  2. Do not assume SHORT form for non-special addresses – non-special addresses must be LONG (64 hex chars) in strict mode.
  3. Do not use the Hex class for account addresses – use AccountAddress only (per SDK docs).

Address format (AIP-40)

  • Length: 32 bytes (64 hex chars in LONG form).
  • String: Must start with 0x. LONG = 0x + 64 hex chars; SHORT = shortest form (e.g. 0x1, 0xf).
  • Special addresses: 0x00xf (last byte < 16, rest zero). These may be written in SHORT form (0x1, 0xa).
  • Reference: AIP-40.

Creating AccountAddress

From string (recommended: relaxed)

import { AccountAddress } from "@aptos-labs/ts-sdk";

// Relaxed: accepts with or without 0x, SHORT or LONG
const addr1 = AccountAddress.from("0x1");
const addr2 = AccountAddress.from("0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c");
const addr3 = AccountAddress.from("1"); // no 0x ok

From string (strict AIP-40)

// Strict: LONG (0x + 64 chars) or SHORT only for special (0x0–0xf)
const addrStrict = AccountAddress.fromStringStrict(
  "0x0000000000000000000000000000000000000000000000000000000000000001"
);
// Or use fromStrict for any AccountAddressInput
const a = AccountAddress.fromStrict("0x1"); // ok: special address in SHORT form

From bytes

const bytes = new Uint8Array(32);
bytes[31] = 1;
const addr = new AccountAddress(bytes);
// or
const addrFrom = AccountAddress.from(bytes);

Built-in constants

AccountAddress.ZERO; // 0x0
AccountAddress.ONE; // 0x1
AccountAddress.TWO; // 0x2
AccountAddress.THREE; // 0x3
AccountAddress.FOUR; // 0x4
AccountAddress.A; // 0xa

String output

MethodUse case
addr.toString()AIP-40 default: SHORT for special, LONG for others
addr.toStringLong()Always 0x + 64 hex chars
addr.toStringShort()Shortest form (no leading zeros)
addr.toStringLongWithoutPrefix()64 hex chars, no 0x
const addr = AccountAddress.from("0x1");
addr.toString(); // "0x1"
addr.toStringLong(); // "0x0000...0001" (64 chars after 0x)

Validation

const result = AccountAddress.isValid({
  input: "0x1",
  strict: false
});
if (result.valid) {
  // use address
} else {
  console.log(result.invalidReason, result.invalidReasonMessage);
}

Derived addresses (object / resource / token / user-derived)

Import from @aptos-labs/ts-sdk (via core):

import {
  AccountAddress,
  createObjectAddress,
  createResourceAddress,
  createTokenAddress,
  createUserDerivedObjectAddress
} from "@aptos-labs/ts-sdk";

Object address (e.g. named object)

const creator = AccountAddress.from("0x120e79e45d21ef439963580c77a023e2729db799e96e61f878fac98fde5b9cc9");
const seed = "migration::migration_contract"; // or Uint8Array
const objectAddr = createObjectAddress(creator, seed);
// objectAddr.toString() => deterministic 0x... address

Resource account address

const creator = AccountAddress.from("0x41e724e1d4fce6472ffcb5c9886770893eb49489e3f531d0aa97bf951e66d70c");
const seed = "create_resource::create_resource";
const resourceAddr = createResourceAddress(creator, seed);

Token (NFT) object address

const creator = AccountAddress.from("0x9d518b9b84f327eafc5f6632200ea224a818a935ffd6be5d78ada250bbc44a6");
const collectionName = "SuperV Villains";
const tokenName = "Nami #5962";
const tokenAddr = createTokenAddress(creator, collectionName, tokenName);
// Internally: seed = `${collectionName}::${tokenName}` -> createObjectAddress(creator, seed)

User-derived object address

const sourceAddress = AccountAddress.from("0x653a60dab27fe8f3859414973d218e1b7551c778a8650a7055a85c0f8041b2a4");
const deriveFromAddress = AccountAddress.from("0xa");
const userDerivedAddr = createUserDerivedObjectAddress(sourceAddress, deriveFromAddress);

Equality and serialization

const a = AccountAddress.from("0x1");
const b = AccountAddress.from("0x0000000000000000000000000000000000000000000000000000000000000001");
a.equals(b); // true

// BCS: use serializer or SDK entry/script helpers in transaction building

Common mistakes

MistakeCorrect approach
Using Hex for account addressUse AccountAddress only
Comparing with === on stringsUse addr1.equals(addr2) or compare after AccountAddress.from()
Using SHORT for non-special in strictUse LONG (0x + 64 hex chars) or AccountAddress.from() (relaxed)
Hand-rolling object address hashUse createObjectAddress / createTokenAddress / createResourceAddress / createUserDerivedObjectAddress

References

Comments

Loading comments...