PHP code example of webworker01 / komodophp

1. Go to this page and download the library: Download webworker01/komodophp 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/ */

    

webworker01 / komodophp example snippets


use webworker01\Komodo\Komodo;
use BitWasp\Bitcoin\Address\AddressCreator;

$komodo = new Komodo();
$addrCreator = new AddressCreator();

$addressInput = 'RWEBo1Yp4uGkeXPi1ZGQARfLPkGmoW1MwY';

try {
    $address = $addrCreator->fromString($addressInput, $komodo);
} catch ( \BitWasp\Bitcoin\Exceptions\UnrecognizedAddressException $e) {
    $errormessage = 'The address you entered is not valid, please try again';
    echo $errormessage;
}

use webworker01\Komodo\Electrum;

$electrum = new Electrum();

$electrum->connect($electrumhost, $electrumport);
$unspent = $electrum->blockchainAddressListunspent($address);

use webworker01\Komodo\Cli;

$cli = new Cli();

$notarizations = $cli->run('getaddresstxids', [['addresses' => [$notarizationAddress], 'start' => $currentblock, 'end' => $currentendblock]] );

foreach ($notarizations as $tx) {
    $rawtx = $cli->run('getrawtransaction', [$tx, 1]);
}

use webworker01\Komodo\Opreturn;

$opreturn = new Opreturn();

$notarisationdata = $opreturn->decode($rawtx->vout[1]->scriptPubKey->hex);