tonweb-utils
This is a sub package of TonWeb.
This contains useful utility functions for Dapp developers: work with TON Addresses, gram values, byte arrays, hex, hash functions.
Install
tonweb-utils is already included in the main package:
npm install tonweb
import TonWeb from "tonweb";
TonWeb.utils;
const tonweb = new TonWeb();
tonweb.utils;
You can use the tonweb-utils separately, without the main package:
npm install tonweb-utils
import {Address, toNano, ...} from "tonweb-utils"
Address Class
const Address = TonWeb.utils.Address;
const address = new Address(anyForm: string | Address);
address.isUserFriendly: boolean
address.isUrlSafe: boolean
address.isBounceable: boolean
address.isTestOnly: boolean
address.wc: number
address.hashPart: Uint8Array
address.toString(isUserFriendly?: boolean, isUrlSafe?: boolean, isBounceable?: boolean, isTestOnly?: boolean): string
Functions
TonWeb.utils.
-
BN - "bn.js" library
-
nacl - "tweetnacl" library
-
Address - Address class
-
toNano(amount: number | BN | string): BN
-
fromNano(amount: number | BN | string): string
-
bytesToHex(bytes: Uint8Array): string
-
hexToBytes(s: string): Uint8Array
-
stringToBytes(s: string, size?: number): Uint8Array
-
crc32c(bytes: Uint8Array): Uint8Array
-
crc16(data: ArrayLike): Uint8Array
-
concatBytes(a: Uint8Array, b: Uint8Array): Uint8Array
-
bytesToBase64(bytes: Uint8Array): string
-
base64ToBytes(base64: string): Uint8Array
Authors
@rulon and @tolyayanot