xrplwin / xrpl-nfttxmutationparser
Parse XRPL NFT transaction to context aware object providing direction, token id and roles.
Requires
- php: ^8.1.0
Requires (Dev)
- phpunit/phpunit: ^10.1
- symfony/var-dumper: ^6.1
README
XRPL NFT Transaction Mutation Parser for PHP
Supporting networks
- XRPL
- Xahau
Description
Parses NFToken and URIToken (referred as NFT) Transactions (NFTokenMint
, URITokenMint
, NFTokenBurn
, URITokenBurn
, NFTokenAcceptOffer
, URITokenBuy
, NFTokenCancelOffer
, URITokenCancelSellOffer
, NFTokenCreateOffer
, URITokenCreateSellOffer
, Remit
) with account context and returns affected NFT, direction that NFT was transferred, minted or destroyed, and outputs roles referencing account has in specific transaction.
With this parser you can find out what has happened with referencing account after transaction was executed. For example when token is minted - parser will output token ID and direction IN, this means referenced account was minter and new token is added to reference account ownership.
Remit (XLS-55)
Remit Transaction Type can mint a single URIToken which is present in this transaction like any other NFT. Additionally Remit can transfer none, one or more existing URIToken-s from Account to Destination, those tokens are present in nfts
and ref.nfts
array key, sending Account has role 'SELLER' and receiver Destination has role 'OWNER'.
What is checked:
- Token id - affected token ID in question
- Token direction - minted - IN, burned, OUT, sold - OUT, bought - IN
- Roles - role of referencing account in this transaction, is it minter, burner, seller, buyer, broker, or issuer
- Remitted URITokens - list of tokens transferred in
Remit
transaction type
Note about NFToken (XLS-20) issuer:
Issuer can only happen in NFTokenAcceptOffer
transaction type, it is extracted from modified AccountRoot node by checking if balance has been changed. If yes then this account gained percentage of sale, and it is issuer of NFToken.
Note
This package is provided as is, please test it yourself first.
Found a bug? Report issue here
Requirements
- PHP 8.1 or higher
- Composer
Installation
To install run
composer require xrplwin/xrpl-nfttxmutationparser
Usage
use XRPLWin\XRPLNFTTxMutatationParser\NFTTxMutationParser; $txResult = [ "Account" => "rBcd..." "Fee" => "1000", //... ]; $parser = new NFTTxMutationParser( "rAbc...", //This is reference account (object)$txResult //This is transaction result ); $parsedTransaction = $parser->result(); print_r($parsedTransaction); /* ┐ ├ Output for $parsedTransaction: ├ Array ( ├ [nft] => 00082710... ├ [nfts] => [] ├ [context] => null ├ [ref] => Array ├ ( ├ [account] => rAbc... ├ [nft] => 00082710... ├ [nfts] => [] ├ [direction] => IN ├ [roles] => Array ├ ( ├ [0] => OWNER ├ ) ├ ) ├ ) ┴ */
Response
Running tests
Run all tests in "tests" directory.
composer test
or
./vendor/bin/phpunit --testdox
Demo
See this in action on XRPLWin Playground