Guide type mapping between Move and TypeScript when using @aptos-labs/ts-sdk: numeric types (especially
u128/u256), address, TypeTag, and functionArguments / typeArguments.
bigint for u128 and u256 – in both view results and functionArguments; JavaScript number loses
precision above 2^53.string for address in payloads – e.g. "0x1" or accountAddress.toString(); SDK accepts
AccountAddressInput (string or AccountAddress).typeArguments for generic Move functions – e.g. coin type ["0x1::aptos_coin::AptosCoin"] for
coin::balance or coin::transfer.BigInt(result[0] as string) for u128.number for u128/u256 – precision loss; use bigint.bigint if value can exceed Number.MAX_SAFE_INTEGER.balance<CoinType>).Move typeTypeScript typeExampleu8, u16, u32number255, 65535u64number | bigintPrefer bigint for large valuesu128, u256bigintBigInt("340282366920938463463374607431768211455")i8..i64 (Move 2.3+)number | bigintUse bigint for i64 when largei128, i256bigintBigInt("-...")boolbooleantrueaddressstring"0x1"signer—Not passed from TS; signer is the transaction sendervectorUint8Array | string (hex)new Uint8Array([1,2,3]) or hexvectorT[][1, 2, 3]Stringstring"hello"Objectstring (object address)objectAddress.toString()OptionT | nullValue or null
Order and types must match the Move entry/view function parameters:
typescript
// Move: public fun transfer<CoinType>(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 as string
1000n // u64 as bigint (or number if small)
]
}
});
For generic Move functions, pass full type strings ( address::module::StructName):
typescript
// Move: balance<CoinType>(addr): u64
typeArguments: ["0x1::aptos_coin::AptosCoin"];
// Move: transfer<CoinType>(to, amount)
typeArguments: ["0x1::aptos_coin::AptosCoin"];
typescript
const result = await aptos.view({
payload: {
function: "0x1::coin::balance",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [accountAddress]
}
});
// result is an array; u128 often returned as string in JSON
const balance = BigInt(result[0] as string);
When building payloads programmatically or parsing type strings:
typescript
import { TypeTag } from "@aptos-labs/ts-sdk";
// Parser for type tag strings
import { parseTypeTag } from "@aptos-labs/ts-sdk";
const tag = parseTypeTag("0x1::aptos_coin::AptosCoin");
Use typeArguments as string array in simple cases; use TypeTag when the SDK API expects it.
Pass object address as string (LONG or SHORT per AIP-40):
typescript
functionArguments: [
nftObjectAddress.toString(), // or "0x..."
price
];
MistakeCorrect approachPassing number for u128 amountUse 1000000n or BigInt("...")Omitting typeArguments for coin::balanceAdd typeArguments: ["0x1::aptos_coin::AptosCoin"]Using result[0] as number for u128Use BigInt(result[0] as string)Wrong order of functionArgumentsMatch Move parameter order exactly
src/transactions/typeTag/, src/transactions/instances/transactionArgument.ts, view and build APIs