Module utils

Module utils

Misc utility Functions.

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

Types

AddressStringFormatAccountIdVariant

AddressStringFormatHexVariant

AddressStringFormatBase64Variant

AddressStringFormat

AccountAddressType

ParamsOfConvertAddress

ResultOfConvertAddress

ParamsOfGetAddressType

ResultOfGetAddressType

ParamsOfCalcStorageFee

ResultOfCalcStorageFee

ParamsOfCompressZstd

ResultOfCompressZstd

ParamsOfDecompressZstd

ResultOfDecompressZstd

Functions

convert_address

Converts address from any TON format to any TON format

NOTE: Sync version is available only for lib-node binding.

Parameters

  • address: string – Account address in any TON format.

  • output_format: AddressStringFormat – Specify the format to convert to.

Result

  • address: string – Address in the specified format

get_address_type

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

NOTE: Sync version is available only for lib-node binding.

Parameters

  • address: string – Account address in any TON format.

Result

calc_storage_fee

Calculates storage fee for an account over a specified time period

NOTE: Sync version is available only for lib-node binding.

Parameters

  • account: string

  • period: number

Result

  • fee: string

compress_zstd

Compresses data using Zstandard algorithm

NOTE: Sync version is available only for lib-node binding.

Parameters

  • 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 (currently 3).

Result

  • compressed: string – Compressed data. Must be encoded as base64.

decompress_zstd

Decompresses data using Zstandard algorithm

NOTE: Sync version is available only for lib-node binding.

Parameters

  • compressed: string – Compressed data. Must be encoded as base64.

Result

  • decompressed: string – Decompressed data. Must be encoded as base64.

Types

AddressStringFormatAccountIdVariant

AddressStringFormatHexVariant

AddressStringFormatBase64Variant

  • url: boolean

  • test: boolean

  • bounce: boolean

AddressStringFormat

Depends on value of the type field.

When type is 'AccountId'

When type is 'Hex'

When type is 'Base64'

  • url: boolean

  • test: boolean

  • bounce: boolean

Variant constructors:

AccountAddressType

One of the following value:

  • AccountId = "AccountId"

  • Hex = "Hex"

  • Base64 = "Base64"

ParamsOfConvertAddress

  • address: string – Account address in any TON format.

  • output_format: AddressStringFormat – Specify the format to convert to.

ResultOfConvertAddress

  • address: string – Address in the specified format

ParamsOfGetAddressType

  • address: string – Account address in any TON format.

ResultOfGetAddressType

ParamsOfCalcStorageFee

  • account: string

  • period: number

ResultOfCalcStorageFee

  • fee: string

ParamsOfCompressZstd

  • 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 (currently 3).

ResultOfCompressZstd

  • compressed: string – Compressed data. Must be encoded as base64.

ParamsOfDecompressZstd

  • compressed: string – Compressed data. Must be encoded as base64.

ResultOfDecompressZstd

  • decompressed: string – Decompressed data. Must be encoded as base64.

Last updated

Was this helpful?