BOC manipulation module.
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_code_from_tvc – Extracts code from TVC contract image
cache_get – Get BOC from cache
cache_set – Save BOC into cache
cache_unpin – Unpin BOCs with specified pin.
encode_boc – Encodes BOC from builder operations.
BuilderOp – Cell builder operation.
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>;
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>;
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>;
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>;
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>;
boc
: string – BOC encoded as base64id
: string – Shardstate identificatorworkchain_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>;
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>;
boc
: string – BOC encoded as base64
hash
: string – BOC root hash encoded with hex
Extracts code from TVC contract image
type ParamsOfGetCodeFromTvc = {
tvc: string
}
type ResultOfGetCodeFromTvc = {
code: string
}
function get_code_from_tvc(
params: ParamsOfGetCodeFromTvc,
): Promise<ResultOfGetCodeFromTvc>;
tvc
: string – Contract TVC image encoded as base64
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>;
boc_ref
: string – Reference to the cached BOC
boc
?: string – BOC encoded as base64.
Save BOC into cache
type ParamsOfBocCacheSet = {
boc: string,
cache_type: BocCacheType
}
type ResultOfBocCacheSet = {
boc_ref: string
}
function cache_set(
params: ParamsOfBocCacheSet,
): Promise<ResultOfBocCacheSet>;
boc
: string – BOC encoded as base64 or BOC referencecache_type
: BocCacheType – Cache type
boc_ref
: string – Reference to the cached BOC
Unpin BOCs with specified pin.
BOCs which don't have another pins will be removed from cache
type ParamsOfBocCacheUnpin = {
pin: string,
boc_ref?: string
}
function cache_unpin(
params: ParamsOfBocCacheUnpin,
): Promise<void>;
pin
: string – Pinned nameboc_ref
?: string – Reference to the cached BOC.
If it is provided then only referenced BOC is unpinned
Encodes BOC from builder operations.
type ParamsOfEncodeBoc = {
builder: BuilderOp[],
boc_cache?: BocCacheType
}
type ResultOfEncodeBoc = {
boc: string
}
function encode_boc(
params: ParamsOfEncodeBoc,
): Promise<ResultOfEncodeBoc>;
builder
: BuilderOp[] – Cell builder operations.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.
type BocCacheType = {
type: 'Pinned'
pin: string
} | {
type: 'Unpinned'
}
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
pin
: string
When type is 'Unpinned'
Variant constructors:
function bocCacheTypePinned(pin: string): BocCacheType;
function bocCacheTypeUnpinned(): BocCacheType;
enum BocErrorCode {
InvalidBoc = 201,
SerializationError = 202,
InappropriateBlock = 203,
MissingSourceBoc = 204,
InsufficientCacheSize = 205,
BocRefNotFound = 206,
InvalidBocRef = 207
}
One of the following value:
InvalidBoc = 201
SerializationError = 202
InappropriateBlock = 203
MissingSourceBoc = 204
InsufficientCacheSize = 205
BocRefNotFound = 206
InvalidBocRef = 207
type ParamsOfParse = {
boc: string
}
boc
: string – BOC encoded as base64
type ResultOfParse = {
parsed: any
}
parsed
: any – JSON containing parsed BOC
type ParamsOfParseShardstate = {
boc: string,
id: string,
workchain_id: number
}
boc
: string – BOC encoded as base64id
: string – Shardstate identificatorworkchain_id
: number – Workchain shardstate belongs to
type ParamsOfGetBlockchainConfig = {
block_boc: string
}
block_boc
: string – Key block BOC or zerostate BOC encoded as base64
type ResultOfGetBlockchainConfig = {
config_boc: string
}
config_boc
: string – Blockchain config BOC encoded as base64
type ParamsOfGetBocHash = {
boc: string
}
boc
: string – BOC encoded as base64
type ResultOfGetBocHash = {
hash: string
}
hash
: string – BOC root hash encoded with hex
type ParamsOfGetCodeFromTvc = {
tvc: string
}
tvc
: string – Contract TVC image encoded as base64
type ResultOfGetCodeFromTvc = {
code: string
}
code
: string – Contract code encoded as base64
type ParamsOfBocCacheGet = {
boc_ref: string
}
boc_ref
: string – Reference to the cached BOC
type ResultOfBocCacheGet = {
boc?: string
}
boc
?: string – BOC encoded as base64.
type ParamsOfBocCacheSet = {
boc: string,
cache_type: BocCacheType
}
boc
: string – BOC encoded as base64 or BOC referencecache_type
: BocCacheType – Cache type
type ResultOfBocCacheSet = {
boc_ref: string
}
boc_ref
: string – Reference to the cached BOC
type ParamsOfBocCacheUnpin = {
pin: string,
boc_ref?: string
}
pin
: string – Pinned nameboc_ref
?: string – Reference to the cached BOC.
If it is provided then only referenced BOC is unpinned
Cell builder operation.
type BuilderOp = {
type: 'Integer'
size: number,
value: any
} | {
type: 'BitString'
value: string
} | {
type: 'Cell'
builder: BuilderOp[]
} | {
type: 'CellBoc'
boc: string
}
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.g0x123
,0X123
,-0x123
.
When type is 'BitString'
Append bit string to cell data.
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
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 withbase64
or BOC cache key.
Variant constructors:
function builderOpInteger(size: number, value: any): BuilderOp;
function builderOpBitString(value: string): BuilderOp;
function builderOpCell(builder: BuilderOp[]): BuilderOp;
function builderOpCellBoc(boc: string): BuilderOp;
type ParamsOfEncodeBoc = {
builder: BuilderOp[],
boc_cache?: BocCacheType
}
builder
: BuilderOp[] – Cell builder operations.boc_cache
?: BocCacheType – Cache type to put the result. The BOC itself returned if no cache type provided.
type ResultOfEncodeBoc = {
boc: string
}
boc
: string – Encoded cell BOC or BOC cache key.