Download the PHP package olifanton/boc without Composer

On this page you can find all versions of the php package olifanton/boc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package boc


⚠️⚠️⚠️ This package is outdated and will not be updated! Use olifanton/interop instead.


BOC (Bag of Cells) PHP serialization library

Tests Latest Stable Version Total Downloads

PHP port of tonweb-boc JS library

Installation

Documentation

Getting started

Install olifanton/boc package via Composer and include autoload script:

Library classes


Olifanton\Boc\BitString

BitString is a class that allows you to manipulate binary data. BitString is at the heart of the PHP representation of TVM Cells. BitString is memory optimized for storing binary data. Internally, BitString uses implementation of Uint8Array provided by ajf/typed-arrays package and is used as the base type for transferring binary data between parts of the Olifanton libraries.

The BitString instance is created with a strictly fixed length. write% (writeBit, writeUint, ...) methods move the internal cursor. If you try to write a value that exceeds the length of the free bits, BitStringException exception will be thrown.

BitString constructor

Parameters:

BitString methods
getFreeBits(): int

Returns unused bits length of BitString.

getUsedBits(): int

Returns used bits length of BitString.

getUsedBytes(): int

Returns used bytes length of BitString.

get(): bool

Returns a bit value at $n position.

on(): void

Sets a bit value to 1 at position $n.

off(): void

Sets a bit value to 0 at position $n.

toggle(): void

Toggle (inverse) bit value at position $n.

iterate(): \Generator

Returns Generator of used bits.

Example:

writeBit(): void

Writes bit and increase BitString internal cursor.

writeBitArray(): void

Writes array of bits.

Example:

writeUint(): void

Writes $bitLength-bit unsigned integer.

writeInt(): void

Writes $bitLength-bit signed integer.

writeUint8(): void

Alias of writeUint() method with predefined $bitLength parameter value.

writeBytes(): void

Write array of unsigned 8-bit integers.

writeString(): void

Writes UTF-8 string.

writeCoins(): void

Writes coins in nanotoncoins. 1 TON === 1000000000 (10^9) nanotoncoins.

writeAddress(): void

Writes TON address. See Address implementation in olifanton/utils package.

writeBitString(): void

Writes another BitString to this BitString.

clone(): BitString

Clones this BitString and returns new BitString instance.

toHex(): string

Returns hex string representation of BitString.

getImmutableArray(): Uint8Array

Returns immutable copy of internal Uint8Array.

getLength(): int

Returns size of BitString in bits.


Olifanton\Boc\Cell

Cell is a class that implements the concept of TVM Cells in PHP. To create new and process received messages from the blockchain, you will work with instances of the Cell class.

Cell constructor

Without parameters.

Cell methods
fromBoc(): Array\<Cell>

Creates array of Cell's from byte array or hex string.

oneFromBoc(): Cell

Fetch one root Cell from byte array or hex string.

writeCell(): void

Writes another Cell to this cell and returns this cell. Mutable method.

getMaxDepth(): int

Returns max depth of child cells.

getBits(): BitString

Returns internal BitString instance for writing and reading.

getRefs(): ArrayObject\<Cell>

Returns Array-like object of children cells.

hash(): Uint8Array

Returns SHA-256 hash of this Cell.

print(): string

Recursively prints cell's content like Fift.

toBoc(): Uint8Array

Creates BoC Byte array.


Olifanton\Boc\Slice

Slice is the type of cell slices. A cell can be transformed into a slice, and then the data bits and references to other cells from the cell can be obtained by loading them from the slice.

load% (loadBit, loadUint, ...) methods move the Slice internal cursor. If you try to read a value that exceeds the length of the free bits, SliceException exception will be thrown.

Slice constructor

Parameters:

Slice methods
getFreeBits(): int

Returns the unread bits according to the internal cursor.

get(): bool

Returns a bit value at position $n.

loadBit(): bool

Reads a bit and moves the cursor.

loadBits(): Uint8Array

Reads bit array.

loadUint(): BigInteger

Reads unsigned integer.

loadInt(): BigInteger

Reads signed integer.

loadVarUint(): BigInteger
loadCoins(): BigInteger

Reads TON amount in nanotoncoins.

loadAddress(): ?Address

Reads Address.

loadRef(): Slice

Reads Slice of children Cell.


Tests


License

MIT


All versions of boc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
myclabs/deep-copy Version ^1.11
olifanton/utils Version ^0.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package olifanton/boc contains the following files

Loading the files please wait ....