1. Go to this page and download the library: Download olifanton/boc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
olifanton / boc example snippets
declare(strict_types=1);
se Olifanton\Boc\Cell;
// Now you can use BoC classes
/**
* @param int $length
*/
public function __construct(int $length)
/**
* @param int $n Position
*/
public function get(int $n): bool
/**
* @param int $n Position
*/
public function on(int $n): void
/**
* @param int $n Position
*/
public function off(int $n): void
/**
* @param int $n Position
*/
public function toggle(int $n): void
declare(strict_types=1);
use Olifanton\Boc\BitString;
$bs = new BitString(4);
$bs->writeBit(1);
$bs->writeBit(0);
$bs->writeBit(1);
$bs->writeBit(1);
foreach ($bs->iterate() as $b) {
echo (int)$b;
}
// Prints "1011"
/**
* @param int|bool $b
*/
public function writeBit(int | bool $b): void
/**
* @param array<int | bool> $ba Array of bits
*/
public function writeBitArray(array $ba): void
declare(strict_types=1);
use Olifanton\Boc\BitString;
$bs = new BitString(4);
$bs->writeBitArray([1, false, 0, true]);
foreach ($bs->iterate() as $b) {
echo (int)$b;
}
// Prints "1001"
/**
* @param int|\Brick\Math\BigInteger $number Unsigned integer
* @param int $bitLength Integer size (8, 16, 32, ...)
*/
public function writeUint(int | BigInteger $number, int $bitLength): void
/**
* @param int|\Brick\Math\BigInteger $number Signed integer
* @param int $bitLength Integer size (8, 16, 32, ...)
*/
public function writeInt(int | BigInteger $number, int $bitLength): void
/**
* @param \ajf\TypedArrays\Uint8Array $ui8 Byte array
*/
public function writeBytes(Uint8Array $ui8): void
/**
* @param string $value
*/
public function writeString(string $value): void
/**
* @param int|\Brick\Math\BigInteger $amount
*/
public function writeCoins(int | BigInteger $amount): void;
/**
* @param \Olifanton\Utils\Address|null $address TON Address
*/
public function writeAddress(?Address $address): void
/**
* @param \Olifanton\Boc\BitString $anotherBitString BitString instance
*/
public function writeBitString(BitString $anotherBitString): void
/**
* @param string|Uint8Array $serializedBoc Serialized BoC
* @return Cell[]
*/
public static function fromBoc(string|Uint8Array $serializedBoc): array