Module boc

Module boc

BOC manipulation module.

Functions

decode_tvc – Decodes tvc according to the tvc spec. Read more about tvc structure here

parse_message – Parses message boc into a JSON

parse_transaction – Parses transaction boc into a JSON

parse_account – Parses account boc into a JSON

parse_block – Parses block boc into a JSON

parse_shardstate – Parses shardstate boc into a JSON

get_blockchain_config – Extract blockchain configuration from key block and also from zerostate.

get_boc_hash – Calculates BOC root hash

get_boc_depth – Calculates BOC depth

get_code_from_tvc – Extracts code from TVC contract image

cache_get – Get BOC from cache

cache_set – Save BOC into cache or increase pin counter for existing pinned BOC

cache_unpin – Unpin BOCs with specified pin defined in the cache_set. Decrease pin reference counter for BOCs with specified pin defined in the cache_set. BOCs which have only 1 pin and its reference counter become 0 will be removed from cache

encode_boc – Encodes bag of cells (BOC) with builder operations. This method provides the same functionality as Solidity TvmBuilder. Resulting BOC of this method can be passed into Solidity and C++ contracts as TvmCell type.

get_code_salt – Returns the contract code's salt if it is present.

set_code_salt – Sets new salt to contract code.

decode_state_init – Decodes contract's initial state into code, data, libraries and special options.

encode_state_init – Encodes initial contract state from code, data, libraries ans special options (see input params)

encode_external_in_message – Encodes a message

get_compiler_version – Returns the compiler version used to compile the code.

Types

BocCacheTypePinnedVariant – Pin the BOC with pin name.

BocCacheTypeUnpinnedVariant – BOC is placed into a common BOC pool with limited size regulated by LRU (least recently used) cache lifecycle.

BocCacheType

BuilderOpIntegerVariant – Append integer to cell data.

BuilderOpBitStringVariant – Append bit string to cell data.

BuilderOpCellVariant – Append ref to nested cells.

BuilderOpCellBocVariant – Append ref to nested cell.

BuilderOpAddressVariant – Address.

BuilderOp – Cell builder operation.

TvcV1Variant

Tvc

TvcV1

BocErrorCode

ParamsOfDecodeTvc

ResultOfDecodeTvc

ParamsOfParse

ResultOfParse

ParamsOfParseShardstate

ParamsOfGetBlockchainConfig

ResultOfGetBlockchainConfig

ParamsOfGetBocHash

ResultOfGetBocHash

ParamsOfGetBocDepth

ResultOfGetBocDepth

ParamsOfGetCodeFromTvc

ResultOfGetCodeFromTvc

ParamsOfBocCacheGet

ResultOfBocCacheGet

ParamsOfBocCacheSet

ResultOfBocCacheSet

ParamsOfBocCacheUnpin

ParamsOfEncodeBoc

ResultOfEncodeBoc

ParamsOfGetCodeSalt

ResultOfGetCodeSalt

ParamsOfSetCodeSalt

ResultOfSetCodeSalt

ParamsOfDecodeStateInit

ResultOfDecodeStateInit

ParamsOfEncodeStateInit

ResultOfEncodeStateInit

ParamsOfEncodeExternalInMessage

ResultOfEncodeExternalInMessage

ParamsOfGetCompilerVersion

ResultOfGetCompilerVersion

Functions

decode_tvc

Decodes tvc according to the tvc spec. Read more about tvc structure here

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

Parameters

  • tvc: string – Contract TVC BOC encoded as base64 or BOC handle

Result

  • tvc: Tvc – Decoded TVC

parse_message

Parses message boc into a JSON

JSON structure is compatible with GraphQL API message object

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

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_transaction

Parses transaction boc into a JSON

JSON structure is compatible with GraphQL API transaction object

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

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_account

Parses account boc into a JSON

JSON structure is compatible with GraphQL API account object

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

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_block

Parses block boc into a JSON

JSON structure is compatible with GraphQL API block object

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

Parameters

  • boc: string – BOC encoded as base64

Result

  • parsed: any – JSON containing parsed BOC

parse_shardstate

Parses shardstate boc into a JSON

JSON structure is compatible with GraphQL API shardstate object

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

Parameters

  • boc: string – BOC encoded as base64

  • id: string – Shardstate identifier

  • workchain_id: number – Workchain shardstate belongs to

Result

  • parsed: any – JSON containing parsed BOC

get_blockchain_config

Extract blockchain configuration from key block and also from zerostate.

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

Parameters

  • block_boc: string – Key block BOC or zerostate BOC encoded as base64

Result

  • config_boc: string – Blockchain config BOC encoded as base64

get_boc_hash

Calculates BOC root hash

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

Parameters

  • boc: string – BOC encoded as base64 or BOC handle

Result

  • hash: string – BOC root hash encoded with hex

get_boc_depth

Calculates BOC depth

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

Parameters

  • boc: string – BOC encoded as base64 or BOC handle

Result

  • depth: number – BOC root cell depth

get_code_from_tvc

Extracts code from TVC contract image

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

Parameters

  • tvc: string – Contract TVC image or image BOC handle

Result

  • code: string – Contract code encoded as base64

cache_get

Get BOC from cache

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

Parameters

  • boc_ref: string – Reference to the cached BOC

Result

  • boc?: string – BOC encoded as base64.

cache_set

Save BOC into cache or increase pin counter for existing pinned BOC

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

Parameters

  • boc: string – BOC encoded as base64 or BOC reference

  • cache_type: BocCacheType – Cache type

Result

  • boc_ref: string – Reference to the cached BOC

cache_unpin

Unpin BOCs with specified pin defined in the cache_set. Decrease pin reference counter for BOCs with specified pin defined in the cache_set. BOCs which have only 1 pin and its reference counter become 0 will be removed from cache

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

Parameters

  • pin: string – Pinned name

  • boc_ref?: string – Reference to the cached BOC. If it is provided then only referenced BOC is unpinned

encode_boc

Encodes bag of cells (BOC) with builder operations. This method provides the same functionality as Solidity TvmBuilder. Resulting BOC of this method can be passed into Solidity and C++ contracts as TvmCell type.

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

Parameters

  • builder: BuilderOp[] – Cell builder operations.

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

Result

  • boc: string – Encoded cell BOC or BOC cache key.

get_code_salt

Returns the contract code's salt if it is present.

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

Parameters

  • code: string – Contract code BOC encoded as base64 or code BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

Result

  • salt?: string – Contract code salt if present. BOC encoded as base64 or BOC handle

set_code_salt

Sets new salt to contract code.

Returns the new contract code with salt.

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

Parameters

  • code: string – Contract code BOC encoded as base64 or code BOC handle

  • salt: string – Code salt to set. BOC encoded as base64 or BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

Result

  • code: string – Contract code with salt set. BOC encoded as base64 or BOC handle

decode_state_init

Decodes contract's initial state into code, data, libraries and special options.

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

Parameters

  • state_init: string – Contract StateInit image BOC encoded as base64 or BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

Result

  • code?: string – Contract code BOC encoded as base64 or BOC handle

  • code_hash?: string – Contract code hash

  • code_depth?: number – Contract code depth

  • data?: string – Contract data BOC encoded as base64 or BOC handle

  • data_hash?: string – Contract data hash

  • data_depth?: number – Contract data depth

  • library?: string – Contract library BOC encoded as base64 or BOC handle

  • tick?: boolean – special.tick field. Specifies the contract ability to handle tick transactions

  • tock?: boolean – special.tock field. Specifies the contract ability to handle tock transactions

  • split_depth?: number – Is present and non-zero only in instances of large smart contracts

  • compiler_version?: string – Compiler version, for example 'sol 0.49.0'

encode_state_init

Encodes initial contract state from code, data, libraries ans special options (see input params)

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

Parameters

  • code?: string – Contract code BOC encoded as base64 or BOC handle

  • data?: string – Contract data BOC encoded as base64 or BOC handle

  • library?: string – Contract library BOC encoded as base64 or BOC handle

  • tick?: boolean – special.tick field. Specifies the contract ability to handle tick transactions

  • tock?: boolean – special.tock field. Specifies the contract ability to handle tock transactions

  • split_depth?: number – Is present and non-zero only in instances of large smart contracts

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

Result

  • state_init: string – Contract StateInit image BOC encoded as base64 or BOC handle of boc_cache parameter was specified

encode_external_in_message

Encodes a message

Allows to encode any external inbound message.

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

Parameters

  • src?: string – Source address.

  • dst: string – Destination address.

  • init?: string – Bag of cells with state init (used in deploy messages).

  • body?: string – Bag of cells with the message body encoded as base64.

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided

Result

  • message: string – Message BOC encoded with base64.

  • message_id: string – Message id.

get_compiler_version

Returns the compiler version used to compile the code.

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

Parameters

  • code: string – Contract code BOC encoded as base64 or code BOC handle

Result

  • version?: string – Compiler version, for example 'sol 0.49.0'

Types

BocCacheTypePinnedVariant

Pin the BOC with pin name.

Such BOC will not be removed from cache until it is unpinned BOCs can have several pins and each of the pins has reference counter indicating how many times the BOC was pinned with the pin. BOC is removed from cache after all references for all pins are unpinned with cache_unpin function calls.

  • pin: string

BocCacheTypeUnpinnedVariant

BOC is placed into a common BOC pool with limited size regulated by LRU (least recently used) cache lifecycle.

BOC resides there until it is replaced with other BOCs if it is not used

BocCacheType

Depends on value of the type field.

When type is 'Pinned'

Pin the BOC with pin name.

Such BOC will not be removed from cache until it is unpinned BOCs can have several pins and each of the pins has reference counter indicating how many times the BOC was pinned with the pin. BOC is removed from cache after all references for all pins are unpinned with cache_unpin function calls.

  • pin: string

When type is 'Unpinned'

BOC is placed into a common BOC pool with limited size regulated by LRU (least recently used) cache lifecycle.

BOC resides there until it is replaced with other BOCs if it is not used

Variant constructors:

BuilderOpIntegerVariant

Append integer to cell data.

  • size: number – Bit size of the value.

  • value: any – Value: - Number containing integer number. e.g. 123, -123. - Decimal string. e.g. "123", "-123". - 0x prefixed hexadecimal string. e.g 0x123, 0X123, -0x123.

BuilderOpBitStringVariant

Append bit string to cell data.

  • value: string – Bit string content using bitstring notation. See TON specification 1.0. Contains hexadecimal string representation: - Can end with _ tag. - Can be prefixed with x or X. - Can be prefixed with x{ or X{ and ended with }. Contains binary string represented as a sequence of 0 and 1 prefixed with n or N. Examples: 1AB, x1ab, X1AB, x{1abc}, X{1ABC} 2D9_, x2D9_, X2D9_, x{2D9_}, X{2D9_} n00101101100, N00101101100

BuilderOpCellVariant

Append ref to nested cells.

  • builder: BuilderOp[] – Nested cell builder.

BuilderOpCellBocVariant

Append ref to nested cell.

  • boc: string – Nested cell BOC encoded with base64 or BOC cache key.

BuilderOpAddressVariant

Address.

  • address: string – Address in a common workchain:account or base64 format.

BuilderOp

Cell builder operation.

Depends on value of the type field.

When type is 'Integer'

Append integer to cell data.

  • size: number – Bit size of the value.

  • value: any – Value: - Number containing integer number. e.g. 123, -123. - Decimal string. e.g. "123", "-123". - 0x prefixed hexadecimal string. e.g 0x123, 0X123, -0x123.

When type is 'BitString'

Append bit string to cell data.

  • value: string – Bit string content using bitstring notation. See TVM specification 1.0. Contains hexadecimal string representation: - Can end with _ tag. - Can be prefixed with x or X. - Can be prefixed with x{ or X{ and ended with }. Contains binary string represented as a sequence of 0 and 1 prefixed with n or N. Examples: 1AB, x1ab, X1AB, x{1abc}, X{1ABC} 2D9_, x2D9_, X2D9_, x{2D9_}, X{2D9_} n00101101100, N00101101100

When type is 'Cell'

Append ref to nested cells.

  • builder: BuilderOp[] – Nested cell builder.

When type is 'CellBoc'

Append ref to nested cell.

  • boc: string – Nested cell BOC encoded with base64 or BOC cache key.

When type is 'Address'

Address.

  • address: string – Address in a common workchain:account or base64 format.

Variant constructors:

TvcV1Variant

Tvc

Depends on value of the type field.

When type is 'V1'

Variant constructors:

TvcV1

  • code?: string

  • description?: string

BocErrorCode

One of the following value:

  • InvalidBoc = 201

  • SerializationError = 202

  • InappropriateBlock = 203

  • MissingSourceBoc = 204

  • InsufficientCacheSize = 205

  • BocRefNotFound = 206

  • InvalidBocRef = 207

ParamsOfDecodeTvc

  • tvc: string – Contract TVC BOC encoded as base64 or BOC handle

ResultOfDecodeTvc

  • tvc: Tvc – Decoded TVC

ParamsOfParse

  • boc: string – BOC encoded as base64

ResultOfParse

  • parsed: any – JSON containing parsed BOC

ParamsOfParseShardstate

  • boc: string – BOC encoded as base64

  • id: string – Shardstate identifier

  • workchain_id: number – Workchain shardstate belongs to

ParamsOfGetBlockchainConfig

  • block_boc: string – Key block BOC or zerostate BOC encoded as base64

ResultOfGetBlockchainConfig

  • config_boc: string – Blockchain config BOC encoded as base64

ParamsOfGetBocHash

  • boc: string – BOC encoded as base64 or BOC handle

ResultOfGetBocHash

  • hash: string – BOC root hash encoded with hex

ParamsOfGetBocDepth

  • boc: string – BOC encoded as base64 or BOC handle

ResultOfGetBocDepth

  • depth: number – BOC root cell depth

ParamsOfGetCodeFromTvc

  • tvc: string – Contract TVC image or image BOC handle

ResultOfGetCodeFromTvc

  • code: string – Contract code encoded as base64

ParamsOfBocCacheGet

  • boc_ref: string – Reference to the cached BOC

ResultOfBocCacheGet

  • boc?: string – BOC encoded as base64.

ParamsOfBocCacheSet

  • boc: string – BOC encoded as base64 or BOC reference

  • cache_type: BocCacheType – Cache type

ResultOfBocCacheSet

  • boc_ref: string – Reference to the cached BOC

ParamsOfBocCacheUnpin

  • pin: string – Pinned name

  • boc_ref?: string – Reference to the cached BOC. If it is provided then only referenced BOC is unpinned

ParamsOfEncodeBoc

  • builder: BuilderOp[] – Cell builder operations.

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

ResultOfEncodeBoc

  • boc: string – Encoded cell BOC or BOC cache key.

ParamsOfGetCodeSalt

  • code: string – Contract code BOC encoded as base64 or code BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

ResultOfGetCodeSalt

  • salt?: string – Contract code salt if present. BOC encoded as base64 or BOC handle

ParamsOfSetCodeSalt

  • code: string – Contract code BOC encoded as base64 or code BOC handle

  • salt: string – Code salt to set. BOC encoded as base64 or BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

ResultOfSetCodeSalt

  • code: string – Contract code with salt set. BOC encoded as base64 or BOC handle

ParamsOfDecodeStateInit

  • state_init: string – Contract StateInit image BOC encoded as base64 or BOC handle

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

ResultOfDecodeStateInit

  • code?: string – Contract code BOC encoded as base64 or BOC handle

  • code_hash?: string – Contract code hash

  • code_depth?: number – Contract code depth

  • data?: string – Contract data BOC encoded as base64 or BOC handle

  • data_hash?: string – Contract data hash

  • data_depth?: number – Contract data depth

  • library?: string – Contract library BOC encoded as base64 or BOC handle

  • tick?: boolean – special.tick field. Specifies the contract ability to handle tick transactions

  • tock?: boolean – special.tock field. Specifies the contract ability to handle tock transactions

  • split_depth?: number – Is present and non-zero only in instances of large smart contracts

  • compiler_version?: string – Compiler version, for example 'sol 0.49.0'

ParamsOfEncodeStateInit

  • code?: string – Contract code BOC encoded as base64 or BOC handle

  • data?: string – Contract data BOC encoded as base64 or BOC handle

  • library?: string – Contract library BOC encoded as base64 or BOC handle

  • tick?: boolean – special.tick field. Specifies the contract ability to handle tick transactions

  • tock?: boolean – special.tock field. Specifies the contract ability to handle tock transactions

  • split_depth?: number – Is present and non-zero only in instances of large smart contracts

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.

ResultOfEncodeStateInit

  • state_init: string – Contract StateInit image BOC encoded as base64 or BOC handle of boc_cache parameter was specified

ParamsOfEncodeExternalInMessage

  • src?: string – Source address.

  • dst: string – Destination address.

  • init?: string – Bag of cells with state init (used in deploy messages).

  • body?: string – Bag of cells with the message body encoded as base64.

  • boc_cache?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided

ResultOfEncodeExternalInMessage

  • message: string – Message BOC encoded with base64.

  • message_id: string – Message id.

ParamsOfGetCompilerVersion

  • code: string – Contract code BOC encoded as base64 or code BOC handle

ResultOfGetCompilerVersion

  • version?: string – Compiler version, for example 'sol 0.49.0'

Last updated