src/Transactions/Serializer.php
public function serialize(): Buffer
    {
        $buffer = new Writer();
        $buffer->writeUInt8(0xff);
        $buffer->writeUInt8($this->transaction['version'] ?? 0x01);
        $buffer->writeUInt8($this->transaction['network'] ?? Network::version());
        $buffer->writeUInt8($this->transaction['type']);
        $buffer->writeUInt32($this->transaction['timestamp']);
        $buffer->writeHex($this->transaction['senderPublicKey']);
        $buffer->writeUInt64($this->transaction['fee']);

        if (isset($this->transaction['vendorField'])) {
            $vendorFieldLength = strlen($this->transaction['vendorField']);
            $buffer->writeUInt8($vendorFieldLength);
            $buffer->writeString($this->transaction['vendorField']);
        } elseif (isset($this->transaction['vendorFieldHex'])) {
            $vendorFieldHexLength = strlen($this->transaction['vendorFieldHex']);
            $buffer->writeUInt8($vendorFieldHexLength / 2);
            $buffer->writeHex($this->transaction['vendorFieldHex']);
        } else {
            $buffer->writeUInt8(0x00);
        }

        $this->handleType($buffer);
        $this->handleSignatures($buffer);

        return new Buffer($buffer->toBytes());
    }
public function serialize(): Buffer
    {
        $buffer = new Writer();
        $buffer->writeUInt8(0xff);
        $buffer->writeUInt8($this->transaction['version'] ?? 0x01);
        $buffer->writeUInt8($this->transaction['network'] ?? Network::version());
        $buffer->writeUInt8($this->transaction['type']);
        $buffer->writeUInt32($this->transaction['timestamp']);
        $buffer->writeHex($this->transaction['senderPublicKey']);
        $buffer->writeUInt64($this->transaction['fee']);

        if (isset($this->transaction['vendorField'])) {
            $vendorFieldLength = strlen($this->transaction['vendorField']);
            $buffer->writeUInt8($vendorFieldLength);
            $buffer->writeString($this->transaction['vendorField']);
        } elseif (isset($this->transaction['vendorFieldHex'])) {
            $vendorFieldHexLength = strlen($this->transaction['vendorFieldHex']);
            $buffer->writeUInt8($vendorFieldHexLength / 2);
            $buffer->writeHex($this->transaction['vendorFieldHex']);
        } else {
            $buffer->writeUInt8(0x00);
        }

        $this->handleType($buffer);
        $this->handleSignatures($buffer);

        return new Buffer($buffer->toBytes());
    }
public function serialize ( ) : Buffer { $ buffer = new Writer ( ) ; $ buffer -> writeUInt8 ( 0xff ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'version' ] ?? 0x01 ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'network' ] ?? Network :: version ( ) ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'type' ] ) ; $ buffer -> writeUInt32 ( $ this -> transaction [ 'timestamp' ] ) ; $ buffer -> writeHex ( $ this -> transaction [ 'senderPublicKey' ] ) ; $ buffer -> writeUInt64 ( $ this -> transaction [ 'fee' ] ) ; if ( isset ( $ this -> transaction [ 'vendorField' ] ) ) { $ vendorFieldLength = strlen ( $ this -> transaction [ 'vendorField' ] ) ; $ buffer -> writeUInt8 ( $ vendorFieldLength ) ; $ buffer -> writeString ( $ this -> transaction [ 'vendorField' ] ) ; } elseif ( isset ( $ this -> transaction [ 'vendorFieldHex' ] ) ) { $ vendorFieldHexLength = strlen ( $ this -> transaction [ 'vendorFieldHex' ] ) ; $ buffer -> writeUInt8 ( $ vendorFieldHexLength / 2 ) ; $ buffer -> writeHex ( $ this -> transaction [ 'vendorFieldHex' ] ) ; } else { $ buffer -> writeUInt8 ( 0x00 ) ; } $ this -> handleType ( $ buffer ) ; $ this -> handleSignatures ( $ buffer ) ; return new Buffer ( $ buffer -> toBytes ( ) ) ; }
Perform AIP11 compliant serialization.

@return \BitWasp\Buffertools\Buffer
Perform AIP11 compliant serialization .