Module boc
BOC manipulation module.
decode_tvc – Decodes tvc according to the tvc spec. Read more about tvc structure here https://github.com/tonlabs/ever-struct/blob/main/src/scheme/mod.rs#L30
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 cacheencode_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.
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)
BocCacheTypeUnpinnedVariant – BOC is placed into a common BOC pool with limited size regulated by LRU (least recently used) cache lifecycle.
Decodes tvc according to the tvc spec. Read more about tvc structure here https://github.com/tonlabs/ever-struct/blob/main/src/scheme/mod.rs#L30
type ParamsOfDecodeTvc = {
tvc: string
}
type ResultOfDecodeTvc = {
tvc: Tvc
}
function decode_tvc(
params: ParamsOfDecodeTvc,
): Promise<ResultOfDecodeTvc>;
function decode_tvc_sync(
params: ParamsOfDecodeTvc,
): ResultOfDecodeTvc;
NOTE: Sync version is available only for
lib-node
binding.tvc
: string – Contract TVC BOC encoded as base64 or BOC handle
Parses message boc into a JSON
JSON structure is compatible with GraphQL API message object
type ParamsOfParse = {
boc: string
}
type ResultOfParse = {
parsed: any
}
function parse_message(
params: ParamsOfParse,
): Promise<ResultOfParse>;
function parse_message_sync(
params: ParamsOfParse,
): ResultOfParse;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64
parsed
: any – JSON containing parsed BOC
Parses transaction boc into a JSON
JSON structure is compatible with GraphQL API transaction object
type ParamsOfParse = {
boc: string
}
type ResultOfParse = {
parsed: any
}
function parse_transaction(
params: ParamsOfParse,
): Promise<ResultOfParse>;
function parse_transaction_sync(
params: ParamsOfParse,
): ResultOfParse;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64
parsed
: any – JSON containing parsed BOC
Parses account boc into a JSON
JSON structure is compatible with GraphQL API account object
type ParamsOfParse = {
boc: string
}
type ResultOfParse = {
parsed: any
}
function parse_account(
params: ParamsOfParse,
): Promise<ResultOfParse>;
function parse_account_sync(
params: ParamsOfParse,
): ResultOfParse;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64
parsed
: any – JSON containing parsed BOC
Parses block boc into a JSON
JSON structure is compatible with GraphQL API block object
type ParamsOfParse = {
boc: string
}
type ResultOfParse = {
parsed: any
}
function parse_block(
params: ParamsOfParse,
): Promise<ResultOfParse>;
function parse_block_sync(
params: ParamsOfParse,
): ResultOfParse;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64
parsed
: any – JSON containing parsed BOC
Parses shardstate boc into a JSON
JSON structure is compatible with GraphQL API shardstate object
type ParamsOfParseShardstate = {
boc: string,
id: string,
workchain_id: number
}
type ResultOfParse = {
parsed: any
}
function parse_shardstate(
params: ParamsOfParseShardstate,
): Promise<ResultOfParse>;
function parse_shardstate_sync(
params: ParamsOfParseShardstate,
): ResultOfParse;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64id
: string – Shardstate identifierworkchain_id
: number – Workchain shardstate belongs to
parsed
: any – JSON containing parsed BOC
Extract blockchain configuration from key block and also from zerostate.
type ParamsOfGetBlockchainConfig = {
block_boc: string
}
type ResultOfGetBlockchainConfig = {
config_boc: string
}
function get_blockchain_config(
params: ParamsOfGetBlockchainConfig,
): Promise<ResultOfGetBlockchainConfig>;
function get_blockchain_config_sync(
params: ParamsOfGetBlockchainConfig,
): ResultOfGetBlockchainConfig;
NOTE: Sync version is available only for
lib-node
binding.block_boc
: string – Key block BOC or zerostate BOC encoded as base64
config_boc
: string – Blockchain config BOC encoded as base64
Calculates BOC root hash
type ParamsOfGetBocHash = {
boc: string
}
type ResultOfGetBocHash = {
hash: string
}
function get_boc_hash(
params: ParamsOfGetBocHash,
): Promise<ResultOfGetBocHash>;
function get_boc_hash_sync(
params: ParamsOfGetBocHash,
): ResultOfGetBocHash;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64 or BOC handle
hash
: string – BOC root hash encoded with hex
Calculates BOC depth
type ParamsOfGetBocDepth = {
boc: string
}
type ResultOfGetBocDepth = {
depth: number
}
function get_boc_depth(
params: ParamsOfGetBocDepth,
): Promise<ResultOfGetBocDepth>;
function get_boc_depth_sync(
params: ParamsOfGetBocDepth,
): ResultOfGetBocDepth;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64 or BOC handle
depth
: number – BOC root cell depth
Extracts code from TVC contract image
type ParamsOfGetCodeFromTvc = {
tvc: string
}
type ResultOfGetCodeFromTvc = {
code: string
}
function get_code_from_tvc(
params: ParamsOfGetCodeFromTvc,
): Promise<ResultOfGetCodeFromTvc>;
function get_code_from_tvc_sync(
params: ParamsOfGetCodeFromTvc,
): ResultOfGetCodeFromTvc;
NOTE: Sync version is available only for
lib-node
binding.tvc
: string – Contract TVC image or image BOC handle
code
: string – Contract code encoded as base64
Get BOC from cache
type ParamsOfBocCacheGet = {
boc_ref: string
}
type ResultOfBocCacheGet = {
boc?: string
}
function cache_get(
params: ParamsOfBocCacheGet,
): Promise<ResultOfBocCacheGet>;
function cache_get_sync(
params: ParamsOfBocCacheGet,
): ResultOfBocCacheGet;
NOTE: Sync version is available only for
lib-node
binding.boc_ref
: string – Reference to the cached BOC
boc
?: string – BOC encoded as base64.
Save BOC into cache or increase pin counter for existing pinned BOC
type ParamsOfBocCacheSet = {
boc: string,
cache_type: BocCacheType
}
type ResultOfBocCacheSet = {
boc_ref: string
}
function cache_set(
params: ParamsOfBocCacheSet,
): Promise<ResultOfBocCacheSet>;
function cache_set_sync(
params: ParamsOfBocCacheSet,
): ResultOfBocCacheSet;
NOTE: Sync version is available only for
lib-node
binding.boc
: string – BOC encoded as base64 or BOC reference
boc_ref
: string – Reference to the cached BOC
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 cachetype ParamsOfBocCacheUnpin = {
pin: string,
boc_ref?: string
}
function cache_unpin(
params: ParamsOfBocCacheUnpin,
): Promise<void>;
function cache_unpin_sync(
params: ParamsOfBocCacheUnpin,
): void;
NOTE: Sync version is available only for
lib-node
binding.pin
: string – Pinned nameboc_ref
?: string – Reference to the cached BOC. If it is provided then only referenced BOC is unpinned
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.
type ParamsOfEncodeBoc = {
builder: BuilderOp[],
boc_cache?: BocCacheType
}
type ResultOfEncodeBoc = {
boc: string
}
function encode_boc(
params: ParamsOfEncodeBoc,
): Promise<ResultOfEncodeBoc>;
function encode_boc_sync(
params: ParamsOfEncodeBoc,
): ResultOfEncodeBoc;
NOTE: Sync version is available only for
lib-node
binding.boc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
boc
: string – Encoded cell BOC or BOC cache key.
Returns the contract code's salt if it is present.
type ParamsOfGetCodeSalt = {
code: string,
boc_cache?: BocCacheType
}
type ResultOfGetCodeSalt = {
salt?: string
}
function get_code_salt(
params: ParamsOfGetCodeSalt,
): Promise<ResultOfGetCodeSalt>;
function get_code_salt_sync(
params: ParamsOfGetCodeSalt,
): ResultOfGetCodeSalt;
NOTE: Sync version is available only for
lib-node
binding.code
: string – Contract code BOC encoded as base64 or code BOC handleboc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
salt
?: string – Contract code salt if present. BOC encoded as base64 or BOC handle
Sets new salt to contract code.
Returns the new contract code with salt.
type ParamsOfSetCodeSalt = {
code: string,
salt: string,
boc_cache?: BocCacheType
}
type ResultOfSetCodeSalt = {
code: string
}
function set_code_salt(
params: ParamsOfSetCodeSalt,
): Promise<ResultOfSetCodeSalt>;
function set_code_salt_sync(
params: ParamsOfSetCodeSalt,
): ResultOfSetCodeSalt;
NOTE: Sync version is available only for
lib-node
binding.code
: string – Contract code BOC encoded as base64 or code BOC handlesalt
: string – Code salt to set. BOC encoded as base64 or BOC handleboc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
code
: string – Contract code with salt set. BOC encoded as base64 or BOC handle
Decodes contract's initial state into code, data, libraries and special options.
type ParamsOfDecodeStateInit = {
state_init: string,
boc_cache?: BocCacheType
}
type ResultOfDecodeStateInit = {
code?: string,
code_hash?: string,
code_depth?: number,
data?: string,
data_hash?: string,
data_depth?: number,
library?: string,
tick?: boolean,
tock?: boolean,
split_depth?: number,
compiler_version?: string
}
function decode_state_init(
params: ParamsOfDecodeStateInit,
): Promise<ResultOfDecodeStateInit>;
function decode_state_init_sync(
params: ParamsOfDecodeStateInit,
): ResultOfDecodeStateInit;
NOTE: Sync version is available only for
lib-node
binding.state_init
: string – Contract StateInit image BOC encoded as base64 or BOC handleboc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
code
?: string – Contract code BOC encoded as base64 or BOC handlecode_hash
?: string – Contract code hashcode_depth
?: number – Contract code depthdata
?: string – Contract data BOC encoded as base64 or BOC handledata_hash
?: string – Contract data hashdata_depth
?: number – Contract data depthlibrary
?: string – Contract library BOC encoded as base64 or BOC handletick
?: boolean –special.tick
field. Specifies the contract ability to handle tick transactionstock
?: boolean –special.tock
field. Specifies the contract ability to handle tock transactionssplit_depth
?: number – Is present and non-zero only in instances of large smart contractscompiler_version
?: string – Compiler version, for example 'sol 0.49.0'
Encodes initial contract state from code, data, libraries ans special options (see input params)
type ParamsOfEncodeStateInit = {
code?: string,
data?: string,
library?: string,
tick?: boolean,
tock?: boolean,
split_depth?: number,
boc_cache?: BocCacheType
}
type ResultOfEncodeStateInit = {
state_init: string
}
function encode_state_init(
params: ParamsOfEncodeStateInit,
): Promise<ResultOfEncodeStateInit>;
function encode_state_init_sync(
params: ParamsOfEncodeStateInit,
): ResultOfEncodeStateInit;
NOTE: Sync version is available only for
lib-node
binding.code
?: string – Contract code BOC encoded as base64 or BOC handledata
?: string – Contract data BOC encoded as base64 or BOC handlelibrary
?: string – Contract library BOC encoded as base64 or BOC handletick
?: boolean –special.tick
field. Specifies the contract ability to handle tick transactionstock
?: boolean –special.tock
field. Specifies the contract ability to handle tock transactionssplit_depth
?: number – Is present and non-zero only in instances of large smart contractsboc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
state_init
: string – Contract StateInit image BOC encoded as base64 or BOC handle of boc_cache parameter was specified
Encodes a message
Allows to encode any external inbound message.
type ParamsOfEncodeExternalInMessage = {
src?: string,
dst: string,
init?: string,
body?: string,
boc_cache?: BocCacheType
}
type ResultOfEncodeExternalInMessage = {
message: string,
message_id: string
}
function encode_external_in_message(
params: ParamsOfEncodeExternalInMessage,
): Promise<ResultOfEncodeExternalInMessage>;
function encode_external_in_message_sync(
params: ParamsOfEncodeExternalInMessage,
): ResultOfEncodeExternalInMessage;
NOTE: Sync version is available only for
lib-node
binding.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
message
: string – Message BOC encoded withbase64
.message_id
: string – Message id.
Returns the compiler version used to compile the code.
type ParamsOfGetCompilerVersion = {
code: string
}
type ResultOfGetCompilerVersion = {
version?: string
}
function get_compiler_version(
params: ParamsOfGetCompilerVersion,
): Promise<ResultOfGetCompilerVersion>;
function get_compiler_version_sync(
params: ParamsOfGetCompilerVersion,
): ResultOfGetCompilerVersion;
NOTE: Sync version is available only for
lib-node
binding.code
: string – Contract code BOC encoded as base64 or code BOC handle
version
?: string – Compiler version, for example 'sol 0.49.0'
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.type BocCacheTypePinnedVariant = {
pin: string
}
pin
: string
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
type BocCacheTypeUnpinnedVariant = {
}
type BocCacheType = ({
type: 'Pinned'
} & BocCacheTypePinnedVariant) | ({
type: 'Unpinned'
} & BocCacheTypeUnpinnedVariant)
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:
function bocCacheTypePinned(pin: string): BocCacheType;
function bocCacheTypeUnpinned(): BocCacheType;
Append integer to cell data.
type BuilderOpIntegerVariant = {
size: number,
value: any
}
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.g0x123
,0X123
,-0x123
.
Append bit string to cell data.
type BuilderOpBitStringVariant = {
value: string
}
value
: string – Bit string content using bitstring notation. SeeTON VM specification
1.0. Contains hexadecimal string representation: - Can end with_
tag. - Can be prefixed withx
orX
. - Can be prefixed withx{
orX{
and ended with}
. Contains binary string represented as a sequence of0
and1
prefixed withn
orN
. Examples:1AB
,x1ab
,X1AB
,x{1abc}
,X{1ABC}
2D9_
,x2D9_
,X2D9_
,x{2D9_}
,X{2D9_}
n00101101100
,N00101101100