1. Go to this page and download the library: Download xrplwin/xrpl-hookparser 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/ */
xrplwin / xrpl-hookparser example snippets
use XRPLWin\XRPLHookParser\TxHookParser;
$tx = (object)[ // Full transaction, containing Account, Destination, meta, ...
"Account": "rA...",
"Amount": "100300000",
"Destination": "rD....",
"Fee": "10000",
...
"meta" => [ ... ],
...
];
$TxHookParser = new TxHookParser($tx);
// All examples below return array:
# List of all hooks in transaction
$hooks = $TxHookParser->hooks();
# List of all accounts that are affected by hooks in transaction
$accounts = $TxHookParser->accounts();
# List of hooks by account*
$accountHooks = $TxHookParser->accountHooks('raddress...');
# List of accounts by hook
$hookAccounts = $TxHookParser->hookAccounts('5EDF6...2DC77');
# List of newly created hooks (new HookDefinition created)
$createdHooks = $TxHookParser->createdHooks();
# List of newly created hooks - detailed
$createdHooksDetails = $TxHookParser->createdHooksDetailed();
# Array key-value parameters contained in created hook
$hookInitialParams = TxHookParser::toParams($createdHooksDetails['5EDF6...2DC77']);
# Check if specific hook is created
$isCreated = $TxHookParser->isHookCreated('5EDF6...2DC77');
# List of destroyed hooks (HookDefinition deleted)
$destroyedHooks = $TxHookParser->destroyedHooks();
# Check if specific hook is destroyed
$isDestroyed = $TxHookParser->isHookDestroyed('5EDF6...2DC77');
# List of uninstalled hooks* (eg. SetHook transaction)
$uninstalledHooks = $TxHookParser->uninstalledHooks();
# List of uninstalled hooks with positions*
$uninstalledHooksPos = $TxHookParser->uninstalledHooksPos();
# List of uninstalled hooks with num uninstalls
$uninstalledHooksStats = $TxHookParser->uninstalledHooksStats();
# List of installed hooks* (eg. SetHook transaction)
$installedHooks = $TxHookParser->installedHooks();
# List of installed hooks with positions*
$installedHooksPos = $TxHookParser->installedHooksPos();
# List of installed hooks with num installs
$installedHooksStats = $TxHookParser->installedHooksStats();
# List of modified hooks*
$modifiedHooks = $TxHookParser->modifiedHooks();
# List of modified hooks with positions*
$modifiedHooksPos = $TxHookParser->modifiedHooksPos();
# List of unmodified hooks*
$unmodifiedHooks = $TxHookParser->unmodifiedHooks();
# List of unmodified hooks with positions*
$unmodifiedHooksPos = $TxHookParser->unmodifiedHooksPos();
# Manual data lookup (lookup any combination of mapped data)
$lookup = $TxHookParser->lookup('raddress...','Hook','installed');
# * Methods that can return multiple same hook hashes, for example if
# account has same hook on two or more positions installed, it is
# important to differentiate hook "instance" on account vs hook
# create and destroy actions. List of hooks always returns unique hashes.
use XRPLWin\XRPLHookParser\HookOn;
$triggered = HookOn::decode('0xfffffffffffffffffffffffffffffffffffffff7fffffffffffc1fffffc00a40'); //array
/*
$triggered = array:26 [
0 => "ttPAYMENT"
1 => "ttESCROW_CREATE"
...
]
*/
//No triggers in this sample:
HookOn::decode('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff');
//Works without prefix:
HookOn::decode('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff');
//Works with uppercase and lowercase:
HookOn::decode('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFF');
HookOn::decode('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFF');
HookOn::decode('0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFF');