<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: xmrrabbitx</title>
    <description>The latest articles on Forem by xmrrabbitx (@xmrrabbitx).</description>
    <link>https://forem.com/xmrrabbitx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F682520%2F1f413dce-9b5b-4fb0-8cb3-5f0366d999cf.png</url>
      <title>Forem: xmrrabbitx</title>
      <link>https://forem.com/xmrrabbitx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/xmrrabbitx"/>
    <language>en</language>
    <item>
      <title>Retrieve Top 10 selling Nfts Using PHP and Infura</title>
      <dc:creator>xmrrabbitx</dc:creator>
      <pubDate>Fri, 14 Apr 2023 10:58:17 +0000</pubDate>
      <link>https://forem.com/xmrrabbitx/retrieve-top-10-selling-nfts-using-php-and-infura-1op8</link>
      <guid>https://forem.com/xmrrabbitx/retrieve-top-10-selling-nfts-using-php-and-infura-1op8</guid>
      <description>&lt;p&gt;If you have read my previous articles, you will notice that the previous version of the NFT history logs library didnt support the top-selling built-in function to retrieve these kinds of logs. but in the latest update, we can now retrieve as many top-selling NFT tokens from a specific contract address as we want in just one line of code.&lt;/p&gt;

&lt;p&gt;You will retrieve the top 10 selling NFTs in five stages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;sign up on the infura website&lt;/li&gt;
&lt;li&gt;setup the provider for the nft history logs library&lt;/li&gt;
&lt;li&gt;retrieve the top 10 selling NFT in one line of code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, why Infura? &lt;a href="https://www.infura.io/" rel="noopener noreferrer"&gt;Infura &lt;/a&gt;is a good option to start with that supports 100K free requests per day. And yes, it has premium plans, but its free plan is enough for us.&lt;/p&gt;

&lt;p&gt;First of all, sign up for free in &lt;a href="https://www.infura.io/" rel="noopener noreferrer"&gt;Infura&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2jxcn060sfeyounaeyim.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2jxcn060sfeyounaeyim.jpeg" alt="infura signup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then create a new API key:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76u55n8bfe222ujoshw0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76u55n8bfe222ujoshw0.jpeg" alt="infura API key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose Web3 API and name your project:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1mczprwtoyeinefprhy.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1mczprwtoyeinefprhy.jpeg" alt="create api key infura"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the url of Ethereum's mainnet. Do not share the API key with anyone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5az1iukitkw9h927d4g.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5az1iukitkw9h927d4g.jpeg" alt="infura endpoint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it's time to use the real magic. Install the latest version of the &lt;a href="https://github.com/xmrrabbitx/NftHistoryLogs#installation" rel="noopener noreferrer"&gt;NFT history logs library&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require nfthistory/nfthistorylogs dev-master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then import it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

require 'vendor/autoload.php'

use Nft\History\nftHistory;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, insert the contract address you want and paste the provider URL that you copied from the Infura website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$contractAddress = '0x00B3e138c6e4b233e5DDed8CfeD200f0c82B536c';
$provider = 'https://mainnet.infura.io/v3/&amp;lt;YOUR API KEY&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this step, create an instance of the nftHistory object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$nfthistory = new nftHistory($contractAdress, $provider);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now call the topSellNfts() function to retrieve as many top-selling nft tokens as you want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$NftHistory-&amp;gt;topSellNfts("multiThread", 10);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, we retrieve the top-selling NFT tokens of a contract address in one single code. We set the mode on multiTread to decrease the time for retrieving. Also, we set 10, which means retrieve the top 10 selling NFT tokens of a contract address. This option can be different based on your needs.&lt;/p&gt;

&lt;p&gt;The output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array(10) {
  [0]=&amp;gt;
  string(4) "0.40"
  [1]=&amp;gt;
  string(4) "0.25"
  [2]=&amp;gt;
  string(4) "0.21"
  [3]=&amp;gt;
  string(4) "0.19"
  [4]=&amp;gt;
  string(4) "0.15"
  [5]=&amp;gt;
  string(4) "0.12"
  [6]=&amp;gt;
  string(4) "0.11"
  [7]=&amp;gt;
  string(4) "0.11"
  [8]=&amp;gt;
  string(4) "0.10"
  [9]=&amp;gt;
  string(4) "0.09"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we successfully retrieved the top 10 out of 83 NFT token sale logs with a single code. Just remember, the bulk request (multiThread) may lead to a rate limit with some providers. Fortunately, Infura is more resilient than that. use carefully. &lt;/p&gt;

&lt;p&gt;The rest of the functions are &lt;a href="https://github.com/xmrrabbitx/NftHistoryLogs#usage" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this is helpful to you. ^__^&lt;/p&gt;

</description>
      <category>infura</category>
      <category>php</category>
      <category>nft</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>How to Rank Top-Selling NFTs Using PHP</title>
      <dc:creator>xmrrabbitx</dc:creator>
      <pubDate>Wed, 22 Mar 2023 01:10:11 +0000</pubDate>
      <link>https://forem.com/xmrrabbitx/how-to-rank-top-selling-nfts-using-php-ha6</link>
      <guid>https://forem.com/xmrrabbitx/how-to-rank-top-selling-nfts-using-php-ha6</guid>
      <description>&lt;p&gt;Well, we know that NFTs are transactions with special token IDs in the Ethereum logs.&lt;/p&gt;

&lt;p&gt;But, what exactly does that mean&lt;/p&gt;

&lt;p&gt;It means every token id includes a “Transfer” transaction, which includes special information in the smart contract. Every “Transfer” transaction includes a set of logs and special events. In fact, the whole of the Ethereum logs concept is a multidimensional array, which we can access to subset information.&lt;/p&gt;

&lt;p&gt;One of these pieces of information is the “value” of a transaction. This value is in WEI format, which you could convert to Ether.&lt;/p&gt;

&lt;p&gt;For more convenient access, we could use the NFT History Logs library.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;p&gt;First, install it via this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; composer require nfthistory/nfthistorylogs v0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then import it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

require 'vendor/autoload.php'

use Nft\History\nftHistory;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, insert the contract address and set the provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$contractAddress = '0x00B3e138c6e4b233e5DDed8CfeD200f0c82B536c';
$provider = 'https://cloudflare-eth.com';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used this contract address, 0x00B3e138c6e4b233e5DDed8CfeD200f0c82B536c, which belongs to The Boy who lost his mind Open Edition by Boss Logic. It is a collection of 82 NFTs at this smart contract address.&lt;/p&gt;

&lt;p&gt;In this article, I want to list the top sales of NFTs using this contract address as a sample.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--twzXbuJ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0r3i8nx2q6059jej9e0w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--twzXbuJ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0r3i8nx2q6059jej9e0w.jpg" alt="The Boy who lost his mind Open Edition by Boss Logic" width="880" height="276"&gt;&lt;/a&gt;&lt;br&gt;
I used the free Cloudflare provider, but you could use your desired provider with an API key.&lt;/p&gt;

&lt;p&gt;In this step, create an instance of the nftHistory object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$nfthistory = new nftHistory($contractAdress, $provider);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, call the getAllTransferTrxHashAndIds() function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$trxHash = $nfthistory-&amp;gt;getAllTransferTrxHashAndIds();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function will give us a list of “Transfer” transaction hashes based on every token id.&lt;/p&gt;

&lt;p&gt;The output of the function is something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var_dump($trxHash);

// output:
array(82) {
   [19400010233]=&amp;gt;
       array(2) {
               [0]=&amp;gt;
              string(66) 
               '0x3982a65f77b8896c19722b8ee2314f2224c767fef25035ba968f57e0cb4a8c8e'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have a set of token ids that includes “Transfer” hashes of specific NFTs. The number 19400010233 is the token id, and the string value with the length of 66 in hexadecimal format is the transaction hash. by using this transaction hash, we could access the value of that transaction.&lt;/p&gt;

&lt;p&gt;So, let’s filter this array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$filterData = array_map(function($log) use($nfthistory){

             return array_map(function($logs) use($nfthistory){

                    $result = $nfthistory-&amp;gt;getTrxByHash($logs);

                     if($result['value'] !== '0x0'){

                                 $logs = $result['value'];
                                 return $logs;

                                 }
             },$log);

},$trxHash);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we used array_map() to iterate over the array in order to filter it out. In this loop, we iterate again, using another array_map() to access every transaction hash. Then, using NFT History Logs , we call the getTrxHash() function to access the value of the transaction in trade.&lt;/p&gt;

&lt;p&gt;The output of this function is a multidimensional array. The “value” index is important to us because it is the hexadecimal value of trade in WEI format. We put in a statement to remove the “0x0”, which means removing zero values.&lt;/p&gt;

&lt;p&gt;In this step, you must have an array like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array(82){
[19400010074]=&amp;gt;
 array(4) {
    [0]=&amp;gt;
    NULL
    [1]=&amp;gt;
    NULL
    [2]=&amp;gt;
    NULL
    [3]=&amp;gt;
    string(17) '0x12dfb0cb5e88000'
  }
  [19400010323]=&amp;gt;
  array(2) {
    [0]=&amp;gt;
   NULL
    [1]=&amp;gt;
    NULL
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the keys of the above array are the token ids that we preserved, and the values of the array are the prices of every transaction. Those whose values are NULL mean there was no sale or the transfer event was equal to zero Ether.&lt;/p&gt;

&lt;p&gt;Now we filter this array out again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$res = array_map(function($log) use($nfthistory){

        $sum = array_sum(array_map('hexdec',$log));

                $nftSumPrice = $nfthistory-&amp;gt;weiToEther($sum);

                return $nftSumPrice;

},$filterData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we sum the prices of every token id that includes more than one price. Then, using the weiToEther() function, we convert the price in WEI format to Ether format and finally return the result.&lt;/p&gt;

&lt;p&gt;The output must look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// output:

array(82) {
  [19400010233]=&amp;gt;
  string(4) '0.00'
  [19400010322]=&amp;gt;
  string(4) '0.00'
  [19400010042]=&amp;gt;
  string(4) '0.00'
 [19400010113]=&amp;gt;
  string(4) '0.00'
  [19400010074]=&amp;gt;
  string(4) '0.08'
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have the sum prices as well as the other ones, which are NULL. We could remove NULL values, but I intentionally kept them to make the comparison better.&lt;/p&gt;

&lt;p&gt;Sort the array in descending order like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arsort($res);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the output be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array(82) {
  [19400010142]=&amp;gt;
  string(4) '0.40'
  [19400010060]=&amp;gt;
  string(4) '0.25'
  [19400010127]=&amp;gt;
  string(4) '0.21'
  [19400010159]=&amp;gt;
  string(4) '0.19'
  [19400010303]=&amp;gt;
  string(4) '0.15'
  [19400010055]=&amp;gt;
  string(4) '0.12'
  [19400010429]=&amp;gt;
  string(4) '0.11'
  [19400010236]=&amp;gt;
  string(4) '0.11'
  [19400010400]=&amp;gt;
  string(4) '0.10'
 [19400010136]=&amp;gt;
 string(4) '0.09'
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above output is the list of the top 10 selling NFTs. in order to be sure about these numbers, first go to this page to search for the first token id (19400010142). Put this number in the search section to access the transaction list of this token id.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dS_Ug7OZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tmxn33im8nzdl3aah7lp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dS_Ug7OZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tmxn33im8nzdl3aah7lp.jpg" alt="Transfer Trxs of a token id" width="880" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, this token ID is transferred twice. If you click on every transaction hash and go to the “value” section, you can see the price of the trade. The first one is 0.4 Ether, and the second one is 0.&lt;/p&gt;

&lt;p&gt;I will try to add these functions as built-in functions to the library. At this moment, you can use it as is.&lt;/p&gt;

&lt;p&gt;The rest of the functions are here.&lt;/p&gt;

&lt;p&gt;If you have any questions, I will respond to you in the comment section. ^__^&lt;/p&gt;

</description>
      <category>nft</category>
      <category>php</category>
      <category>ethereum</category>
      <category>nfthistorylogs</category>
    </item>
    <item>
      <title>How to Fetch NFT Transaction Logs Using PHP</title>
      <dc:creator>xmrrabbitx</dc:creator>
      <pubDate>Thu, 16 Mar 2023 02:24:53 +0000</pubDate>
      <link>https://forem.com/xmrrabbitx/how-to-fetch-nft-transaction-logs-using-php-2ilb</link>
      <guid>https://forem.com/xmrrabbitx/how-to-fetch-nft-transaction-logs-using-php-2ilb</guid>
      <description>&lt;p&gt;You may have experienced entering an NFT market and wanting to find out the number of people who have transferred a specific NFT. Some markets put the transaction history information of each NFT on the website, but some do not. Perhaps one of the reasons is the high volume of transactions made on each smart contract.&lt;/p&gt;

&lt;p&gt;If the latter is the case, then the second option in front of you is the &lt;a href="//Etherscan.io"&gt;Etherscan.io&lt;/a&gt; website. This website makes it easier for us to track NFT smart contracts. It is a very powerful tool, but it is not enough. When you want to check an NFT with a specific ID, you will have a problem, although it provides the possibility of filtering transactions based on specific event signatures such as transfer or approval but not more detailed filtering! Especially if you are in the web development space and need non-graphical tools.&lt;/p&gt;

&lt;p&gt;The third way is to use the Web3 library. Unfortunately, most &lt;a href="https://github.com/web3p/web3.php" rel="noopener noreferrer"&gt;web3 php&lt;/a&gt; libraries are not stable and do not have features as good as web3js.&lt;/p&gt;

&lt;p&gt;With your options laid out, You are definitely looking for a way to get Ethereum logs more easily and filter their information in more detail. The &lt;a href="https://github.com/xmrrabbitx/NftHistoryLogs" rel="noopener noreferrer"&gt;Nft History Logs&lt;/a&gt; library allows you to use the eth_getLogs method with the help of endpoints such as alchemy, infura, or any network where you want to receive the logs of a specific smart contract address according to the event signature.&lt;/p&gt;

&lt;p&gt;You may ask why we should not use an SDK like SDK Alchemy instead of this library. There are several specific reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Most of these SDKs are written by JavaScript&lt;/li&gt;
&lt;li&gt;These SDKs only work with their own dedicated network; for example, the alchemy SDK only works with the alchemy network, which may not be your choice and actually takes away your free will.&lt;/li&gt;
&lt;li&gt;Most Web3 PHP libraries are not stable and have many problems!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To start using this library, type the following command to install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require nfthistory/nfthistorylogs v0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now import the library and create a new instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

require 'vendor/autoload.php'

use Nft\History\nftHistory;

$contractAdress = '0x7F0159D3A639a035797e92861d9F414246735568'

$provider = 'https://cloudflare-eth.com'

$NftHistory = new nftHistory($contractAdress, $provider);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, this class must receive two default variables during construction: one is the address of the NFT smart contract you want, and the other is the provider or endpoint you want to use. Both must be of the string type.&lt;/p&gt;

&lt;p&gt;Here I used Kuddle Koala smart contract #6466. Its smart contract address is 0x7F0159D3A639a035797e92861d9F414246735568 and its token ID is 6466.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wxdl6wdayvx9mccfxgo.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7wxdl6wdayvx9mccfxgo.jpeg" alt="Kuddle Koala smart contract #6466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This token has actually been transferred between two people (two addresses), and the meaning of this transfer is nothing more than the sale of an NFT to another person. We know that NFTs are unique entities, so we have one Kuddle Koala token with ID 6466; the rest of the NFTs have different IDs.&lt;/p&gt;

&lt;p&gt;By using our instance, we call the transferTrxById() function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$res = $NftHistory-&amp;gt;transferTrxById('6466', '0x0', 'latest');

var_dump($res);

//output:
Array
(
[0] =&amp;gt; Array

        (

            [address] =&amp;gt; 0x7f0159d3a639a035797e92861d9f414246735568

           [topics] =&amp;gt; Array

                (

                  [0] =&amp;gt; 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

                   [1] =&amp;gt; 0x0000000000000000000000000000000000000000000000000000000000000000

                  [2] =&amp;gt; 0x0000000000000000000000005b436b7cc93d246d3a62fc7a95339f6fac7d2a4a

                    [3] =&amp;gt; 0x0000000000000000000000000000000000000000000000000000000000001942
                )
            [data] =&amp;gt; 0x
           [blockNumber] =&amp;gt; 0xcd2b8e

            [transactionHash] =&amp;gt;
0xc95b6b17a8453526eba78592bf93b272f75e49b33487b986e81d19a1682eded6        

           [transactionIndex] =&amp;gt; 0x1d

         [blockHash] =&amp;gt;
0x69b72ae82a6e6f2de0750e23e30855cc727605b4c7b3c69814cbc0b3a51b19af

            [logIndex] =&amp;gt; 0x23

            [removed] =&amp;gt;
        )

    [1] =&amp;gt; Array

        (

            [address] =&amp;gt; 0x7f0159d3a639a035797e92861d9f414246735568

            [topics] =&amp;gt; Array

                (

                    [0] =&amp;gt; 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

                    [1] =&amp;gt; 0x0000000000000000000000005b436b7cc93d246d3a62fc7a95339f6fac7d2a4a

                    [2] =&amp;gt; 0x000000000000000000000000cf0b56dfefa3e0051a1772fc585b076a06487c53

                    [3] =&amp;gt; 0x000000000000000000000000000000000000000000000000000000000000194
                )

            [data] =&amp;gt; 0x

            [blockNumber] =&amp;gt; 0xcd3716

            [transactionHash] =&amp;gt; 0x62f59782cc17e5156fda51e27b121d5e9562b4f0d5455c5f04720aeb0a79eb07        

          [transactionIndex] =&amp;gt; 0x10b

            [blockHash] =&amp;gt; 0x8313bae0ff42ba4065bfb1524efb691a5c4c31cfe56defca4c095c803d4bbc3e

            [logIndex] =&amp;gt; 0x210

            [removed] =&amp;gt;

       )

    [2] =&amp;gt; Array

       (

            [address] =&amp;gt; 0x7f0159d3a639a035797e92861d9f414246735568

            [topics] =&amp;gt; Array

                (

                    [0] =&amp;gt; 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

                    [1] =&amp;gt; 0x000000000000000000000000cf0b56dfefa3e0051a1772fc585b076a06487c53

                   [2] =&amp;gt; 0x0000000000000000000000002e6469c5d4256c098ac51b9655dfb27d6f996a0c

                   [3] =&amp;gt; 0x0000000000000000000000000000000000000000000000000000000000001942

               )

          [data] =&amp;gt; 0x

           [blockNumber] =&amp;gt; 0xe703b0
            [transactionHash] =&amp;gt; 0x7b913e65751d493dc46746120e5c50587d183677a7e275535137995d017a438b        

            [transactionIndex] =&amp;gt; 0x16

            [blockHash] =&amp;gt; 0x4837a2daf412be2deebcae9b5c3ecb8a639f0b6e221193b56fe7f42ac79389a3

            [logIndex] =&amp;gt; 0x58

            [removed] =&amp;gt;
        )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, as you can see, the output of this instance was a multidimensional array with 3 transactions, including the NFT mint transaction and the next two transactions of our NFT transfer, which were transferred between 3 people.&lt;/p&gt;

&lt;p&gt;You can access any of the properties of these transactions and analyze them. For example, the data section contains the amount of ether transferred between two addresses during NFT transfer, which is 0x, which means zero, which means no ether was transferred. Be aware that this number is in WEI format, and you need to convert it to Ether. Of course, there are other functions for the convenience of receiving the amount of transferred ether, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$transactionHash = '0x62f59782cc17e5156fda51e27b121d5e9562b4f0d5455c5f04720aeb0a79eb07';

$eventName = 'OrdersMatched';

$etherAmount = $NftHistory-&amp;gt;nftTrxWei($transactionHash, $eventName);

var_dump($etherAmount);

//output
array(1) {

  ['value']=&amp;gt;

  array(1) {

    [0]=&amp;gt;

    array(3) {

      ['buyHash']=&amp;gt;

      string(66) '0x0000000000000000000000000000000000000000000000000000000000000000'

      ['sellHash']=&amp;gt;

      string(66) '0243b8854fe6a9b124e13caed266c59d3cacc1ca4c3246a3cad5a094c53f6d0900'

      ['price']=&amp;gt;

      string(62) '0000000000000000000000000000000000000000000000009869529cdd4000'
    }
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, as shown in the code above, based on the hash value of the transaction, we obtained the sale information for this NFT. Note that the $eventName variable is optional. In fact, instead of receiving all the ether values ​​made on this transaction, we returned only its sale value information.&lt;/p&gt;

&lt;p&gt;Likewise, you can work with the rest of its functions to achieve your desired results more easily.&lt;/p&gt;

&lt;p&gt;You can access other functions of the NFT History Logs library &lt;a href="https://github.com/web3p/web3.php#usage" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;if you have any questions, feel free to ask me in the comment section ^__^&lt;/p&gt;

</description>
      <category>nft</category>
      <category>php</category>
      <category>ethereum</category>
      <category>nftlogs</category>
    </item>
  </channel>
</rss>
