ton3-core / Slice
Cell Slice
- skip
- skipBits
- skipRefs
- skipDict
- loadRef
- preloadRef
- loadMaybeRef
- preloadMaybeRef
- loadBit
- preloadBit
- loadBits
- preloadBits
- loadInt
- preloadInt
- loadBigInt
- preloadBigInt
- loadUint
- preloadUint
- loadBigUint
- preloadBigUint
- loadVarInt
- preloadVarInt
- loadVarBigInt
- preloadVarBigInt
- loadVarUint
- preloadVarUint
- loadVarBigUint
- preloadVarBigUint
- loadBytes
- preloadBytes
- loadString
- preloadString
- loadAddress
- preloadAddress
- loadCoins
- preloadCoins
- loadDict
- preloadDict
- parse
• get
bits(): Bit
[]
Bit
[]
• get
refs(): Cell
[]
Cell
[]
▸ skip(size
): Slice
Alias for .skipBits()
Name | Type |
---|---|
size |
number |
▸ skipBits(size
): Slice
Skip bits from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeBits([ 0, 1, 1, 0 ])
const slice = builder.cell().slice()
console.log(slice.skipBits(2).loadBits(2)) // [ 1, 0 ]
Name | Type | Description |
---|---|---|
size |
number |
Total bits should be skipped |
▸ skipRefs(size
): Slice
Skip refs from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
const cell1 = new Builder().cell()
const cell2 = new Builder().cell()
builder.storeRefs([ cell1, cell2 ])
const slice = builder.cell().slice()
console.log(slice.skipRefs(1).loadRef()) // cell2
Name | Type | Description |
---|---|---|
size |
number |
Total refs should be skipped |
▸ skipDict(): Slice
Skip dict from Slice
▸ loadRef(): Cell
Read ref from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
const ref = new Builder()
builder.storeRef(ref.cell())
const slice = builder.cell().slice()
console.log(slice.loadRef()) // Cell
▸ preloadRef(): Cell
Same as .loadRef() but will not mutate Slice
▸ loadMaybeRef(): Cell
Read maybe ref from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder1 = new Builder()
const builder2 = new Builder()
const ref = new Builder()
builder1.storeBit(0)
builder2
.storeBit(1)
.storeRef(ref.cell())
const slice1 = builder1.cell().slice()
const slice2 = builder2.cell().slice()
console.log(slice1.loadMaybeRef()) // null
console.log(slice2.loadMaybeRef()) // Cell
▸ preloadMaybeRef(): Cell
Same as .loadMaybeRef() but will not mutate Slice
▸ loadBit(): Bit
Read bit from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeBit(1)
const slice = builder.cell().slice()
console.log(slice.loadBit()) // 1
▸ preloadBit(): Bit
Same as .loadBit() but will not mutate Slice
▸ loadBits(size
): Bit
[]
Read bits from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeBits([ 0, 1 ])
const slice = builder.cell().slice()
console.log(slice.loadBits(2)) // [ 0, 1 ]
Name | Type | Description |
---|---|---|
size |
number |
Total bits should be readed to represent requested value |
Bit
[]
▸ preloadBits(size
): Bit
[]
Same as .loadBits() but will not mutate Slice
Name | Type |
---|---|
size |
number |
Bit
[]
▸ loadInt(size
): number
Read int from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeInt(-14, 15)
const slice = builder.cell().slice()
console.log(slice.loadInt(15)) // -14
Name | Type | Description |
---|---|---|
size |
number |
Total bits should be readed to represent requested value |
number
▸ preloadInt(size
): number
Same as .loadInt() but will not mutate Slice
Name | Type |
---|---|
size |
number |
number
▸ loadBigInt(size
): bigint
Same as .loadInt() but will return {@link BigInt}
Name | Type |
---|---|
size |
number |
bigint
▸ preloadBigInt(size
): bigint
Same as .preloadInt() but will return {@link BigInt}
Name | Type |
---|---|
size |
number |
bigint
▸ loadUint(size
): number
Read uint from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeUint(14, 9)
const slice = builder.cell().slice()
console.log(slice.loadUint(9)) // 14
Name | Type | Description |
---|---|---|
size |
number |
Total bits should be readed to represent requested value |
number
▸ preloadUint(size
): number
Same as .loadUint() but will not mutate Slice
Name | Type |
---|---|
size |
number |
number
▸ loadBigUint(size
): bigint
Same as .loadUint() but will return {@link BigInt}
Name | Type |
---|---|
size |
number |
bigint
▸ preloadBigUint(size
): bigint
Same as .preloadUint() but will return {@link BigInt}
Name | Type |
---|---|
size |
number |
bigint
▸ loadVarInt(length
): number
Read variable int from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeVarInt(-101101, 16)
const slice = builder.cell().slice()
console.log(slice.loadVarInt(16)) // -101101
Name | Type | Description |
---|---|---|
length |
number |
Maximum possible number of bits used to store value?? |
number
▸ preloadVarInt(length
): number
Same as .loadVarInt() but will not mutate Slice
Name | Type |
---|---|
length |
number |
number
▸ loadVarBigInt(length
): bigint
Same as .loadVarInt() but will return {@link BigInt}
Name | Type |
---|---|
length |
number |
bigint
▸ preloadVarBigInt(length
): bigint
Same as .preloadVarInt() but will return {@link BigInt}
Name | Type |
---|---|
length |
number |
bigint
▸ loadVarUint(length
): number
Read variable uint from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeVarUint(101101, 16)
const slice = builder.cell().slice()
console.log(slice.loadVarUint(16)) // 101101
Name | Type | Description |
---|---|---|
length |
number |
Maximum possible number of bits used to store value?? |
number
▸ preloadVarUint(length
): number
Same as .loadVarUint() but will not mutate Slice
Name | Type |
---|---|
length |
number |
number
▸ loadVarBigUint(length
): bigint
Same as .loadVarUint() but will return {@link BigInt}
Name | Type |
---|---|
length |
number |
bigint
▸ preloadVarBigUint(length
): bigint
Same as .preloadVarUint() but will return {@link BigInt}
Name | Type |
---|---|
length |
number |
bigint
▸ loadBytes(size
): Uint8Array
Read bytes from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeBytes(new Uint8Array([ 255, 255 ]))
const slice = builder.cell().slice()
console.log(slice.loadBytes(16)) // [ 255, 255 ]
Name | Type |
---|---|
size |
number |
Uint8Array
▸ preloadBytes(size
): Uint8Array
Same as .loadBytes() but will not mutate Slice
Name | Type |
---|---|
size |
number |
Uint8Array
▸ loadString(size?
): string
Read string from Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
builder.storeString('Привет, мир!')
const slice = builder.cell().slice()
console.log(slice.loadString()) // 'Привет, мир!'
Name | Type | Default value |
---|---|---|
size |
number |
null |
string
▸ preloadString(size?
): string
Same as .loadString() but will not mutate Slice
Name | Type | Default value |
---|---|---|
size |
number |
null |
string
▸ loadAddress(): Address
example
import { Builder, Address, Slice } from 'ton3-core'
const builder = new Builder()
const address = new Address('kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny')
builder.storeAddress(address)
const slice = builder.cell().slice()
console.log(slice.loadAddress().toString())
// 'kf_8uRo6OBbQ97jCx2EIuKm8Wmt6Vb15-KsQHFLbKSMiYIny'
▸ preloadAddress(): Address
Same as .loadAddress() but will not mutate Slice
▸ loadCoins(decimals?
): Coins
example
import { Builder, Coins, Slice } from 'ton3-core'
const builder = new Builder()
const coins = new Coins('100')
builder.storeCoins(coins)
const slice = builder.cell().slice()
console.log(slice.loadCoins().toString()) // '100'
Name | Type | Default value |
---|---|---|
decimals |
number |
9 |
▸ preloadCoins(decimals?
): Coins
Same as .loadCoins() but will not mutate Slice
Name | Type | Default value |
---|---|---|
decimals |
number |
9 |
▸ loadDict<K
, V
>(keySize
, options?
): HashmapE
<K
, V
>
example
import { Builder, Slice, HashmapE } from 'ton3-core'
const builder = new Builder()
const dict = new HashmapE(16)
builder.storeDict(dict)
const slice = builder.cell().slice()
const entries = [ ...slice.loadDict() ]
console.log(entries) // []
Name | Type |
---|---|
K |
Bit [] |
V |
Cell |
Name | Type |
---|---|
keySize |
number |
options? |
HashmapOptions <K , V > |
HashmapE
<K
, V
>
▸ preloadDict<K
, V
>(keySize
, options?
): HashmapE
<K
, V
>
Same as .loadDict() but will not mutate Slice
Name | Type |
---|---|
K |
Bit [] |
V |
Cell |
Name | Type |
---|---|
keySize |
number |
options? |
HashmapOptions <K , V > |
HashmapE
<K
, V
>
▸ Static
parse(cell
): Slice
example
import { Builder, Slice } from 'ton3-core'
const builder = new Builder()
const cell = builder.cell()
const slice = Slice.parse(cell)
Name | Type |
---|---|
cell |
Cell |