Misc utility Functions.
convert_address – Converts address from any TON format to any TON format
get_address_type – Validates and returns the type of any TON address.
calc_storage_fee – Calculates storage fee for an account over a specified time period
compress_zstd – Compresses data using Zstandard algorithm
decompress_zstd – Decompresses data using Zstandard algorithm
Converts address from any TON format to any TON format
type ParamsOfConvertAddress = {
address: string,
output_format: AddressStringFormat
}
type ResultOfConvertAddress = {
address: string
}
function convert_address(
params: ParamsOfConvertAddress,
): Promise<ResultOfConvertAddress>;
address
: string – Account address in any TON format.output_format
: AddressStringFormat – Specify the format to convert to.
address
: string – Address in the specified format
Validates and returns the type of any TON address.
Address types are the following
0:919db8e740d50bf349df2eea03fa30c385d846b991ff5542e67098ee833fc7f7
- standard TON address most
commonly used in all cases. Also called as hex address
919db8e740d50bf349df2eea03fa30c385d846b991ff5542e67098ee833fc7f7
- account ID. A part of full
address. Identifies account inside particular workchain
EQCRnbjnQNUL80nfLuoD+jDDhdhGuZH/VULmcJjugz/H9wam
- base64 address. Also called "user-friendly".
Was used at the beginning of TON. Now it is supported for compatibility
type ParamsOfGetAddressType = {
address: string
}
type ResultOfGetAddressType = {
address_type: AccountAddressType
}
function get_address_type(
params: ParamsOfGetAddressType,
): Promise<ResultOfGetAddressType>;
address
: string – Account address in any TON format.
address_type
: AccountAddressType – Account address type.
Calculates storage fee for an account over a specified time period
type ParamsOfCalcStorageFee = {
account: string,
period: number
}
type ResultOfCalcStorageFee = {
fee: string
}
function calc_storage_fee(
params: ParamsOfCalcStorageFee,
): Promise<ResultOfCalcStorageFee>;
account
: stringperiod
: number
fee
: string
Compresses data using Zstandard algorithm
type ParamsOfCompressZstd = {
uncompressed: string,
level?: number
}
type ResultOfCompressZstd = {
compressed: string
}
function compress_zstd(
params: ParamsOfCompressZstd,
): Promise<ResultOfCompressZstd>;
uncompressed
: string – Uncompressed data.
Must be encoded as base64.level
?: number – Compression level, from 1 to 21. Where: 1 - lowest compression level (fastest compression); 21 - highest compression level (slowest compression). If level is omitted, the default compression level is used (currently3
).
compressed
: string – Compressed data.
Must be encoded as base64.
Decompresses data using Zstandard algorithm
type ParamsOfDecompressZstd = {
compressed: string
}
type ResultOfDecompressZstd = {
decompressed: string
}
function decompress_zstd(
params: ParamsOfDecompressZstd,
): Promise<ResultOfDecompressZstd>;
compressed
: string – Compressed data.
Must be encoded as base64.
decompressed
: string – Decompressed data.
Must be encoded as base64.
type AddressStringFormat = {
type: 'AccountId'
} | {
type: 'Hex'
} | {
type: 'Base64'
url: boolean,
test: boolean,
bounce: boolean
}
Depends on value of the type
field.
When type is 'AccountId'
When type is 'Hex'
When type is 'Base64'
url
: booleantest
: booleanbounce
: boolean
Variant constructors:
function addressStringFormatAccountId(): AddressStringFormat;
function addressStringFormatHex(): AddressStringFormat;
function addressStringFormatBase64(url: boolean, test: boolean, bounce: boolean): AddressStringFormat;
enum AccountAddressType {
AccountId = "AccountId",
Hex = "Hex",
Base64 = "Base64"
}
One of the following value:
AccountId = "AccountId"
Hex = "Hex"
Base64 = "Base64"
type ParamsOfConvertAddress = {
address: string,
output_format: AddressStringFormat
}
address
: string – Account address in any TON format.output_format
: AddressStringFormat – Specify the format to convert to.
type ResultOfConvertAddress = {
address: string
}
address
: string – Address in the specified format
type ParamsOfGetAddressType = {
address: string
}
address
: string – Account address in any TON format.
type ResultOfGetAddressType = {
address_type: AccountAddressType
}
address_type
: AccountAddressType – Account address type.
type ParamsOfCalcStorageFee = {
account: string,
period: number
}
account
: stringperiod
: number
type ResultOfCalcStorageFee = {
fee: string
}
fee
: string
type ParamsOfCompressZstd = {
uncompressed: string,
level?: number
}
uncompressed
: string – Uncompressed data.
Must be encoded as base64.level
?: number – Compression level, from 1 to 21. Where: 1 - lowest compression level (fastest compression); 21 - highest compression level (slowest compression). If level is omitted, the default compression level is used (currently3
).
type ResultOfCompressZstd = {
compressed: string
}
compressed
: string – Compressed data.
Must be encoded as base64.
type ParamsOfDecompressZstd = {
compressed: string
}
compressed
: string – Compressed data.
Must be encoded as base64.
type ResultOfDecompressZstd = {
decompressed: string
}
decompressed
: string – Decompressed data.
Must be encoded as base64.