WIN-2308041133\Administrator 6 months ago
parent
commit
f65d39bbf1
1 changed files with 19 additions and 22 deletions
  1. 19 22
      application/api/controller/Pay.php

+ 19 - 22
application/api/controller/Pay.php

@@ -944,27 +944,24 @@ class Pay extends Api
     }
     public function test(){
         $service = Web3Service::instance('bsc', 'usdt', '');
-        $info =$service->getLastTransfer(['0x83105BDFAc1a15DF3C22D019Ac2F2937AC1Ef098'], ['0x8f5f8daC38461E5b1A6b230D30433f8A593CCD57'], 1748315888);
-//// 1. 转换地址为全小写字符串格式
-//        $address = '0x8f5f8dac38461e5b1a6b230d30433f8a593ccd57'; // 注意全小写
-//
-//// 2. 将时间戳转换为区块高度(需要 BSC 节点连接)
-//        $timestamp = 1748315888;
-//        $blockNumber = $service->getBlockNumberByTimestamp($timestamp);
-//
-//// 3. 正确构造过滤条件
-//        $filterOptions = [
-//            'fromBlock' => $blockNumber, // 起始区块高度
-//            'toBlock' => 'latest',       // 结束区块(最新)
-//            'address' => $address,       // 查询地址
-//        ];
-//
-//// 4. 调用方法获取转账记录
-//        try {
-//            $transfers = $service->getLastTransfer($filterOptions);
-//            print_r($transfers);
-//        } catch (\Exception $e) {
-//            echo "Error: " . $e->getMessage();
-//        }
+        $info =$service->getLastTransfer(['0x83105bdfac1a15df3c22d019ac2f2937ac1ef098'], ['0x8f5f8dac38461e5b1a6b230d30433f8a593ccd57'], 1748315888);
+        var_dump($info);die();
+// 1. 确保地址全小写
+        $fromAddress = '0x83105bdfac1a15df3c22d019ac2f2937ac1ef098';
+        $toAddress = '0x8f5f8dac38461e5b1a6b230d30433f8a593ccd57';
+
+// 2. 手动构造最小化的过滤条件
+        $filter = [
+            'fromBlock' => '0x' . dechex(28000000), // 起始区块高度
+            'toBlock' => 'latest',
+            'topics' => [
+                '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', // USDT Transfer事件签名
+                '0x000000000000000000000000' . substr($fromAddress, 2), // 发送方
+                '0x000000000000000000000000' . substr($toAddress, 2)    // 接收方
+            ]
+        ];
+
+// 3. 直接调用底层方法(避免封装方法添加额外参数)
+        $transfers = $service->getEth()->getLogs($filter);
     }
 }