Skip to content

Commit

Permalink
Added getTransactionByHash interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenguoz committed Jun 2, 2023
1 parent 916a961 commit b6d72bb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
10 changes: 8 additions & 2 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ BSC-PHP 目前支持币安智能链的 BNB 和 BEP20 数字资产常用的生成
- *交易转账(离线签名) `transfer(string $from, string $to, float $amount)`
- 查询最新区块 `blockNumber()`
- 根据区块链查询信息 `getBlockByNumber(int $blockID)`
- *根据交易哈希查询信息 `getTransactionReceipt(string $txHash)`
- 根据交易哈希返回交易的收据 `getTransactionReceipt(string $txHash)`
- *根据交易哈希返回关于所请求交易的信息 `getTransactionByHash(string $txHash)`
- *根据交易哈希查询交易状态 `receiptStatus(string $txHash)`

## 快速开始
Expand Down Expand Up @@ -110,11 +111,16 @@ $blockID = 24631027;
$bnb->getBlockByNumber($blockID);
$bep20->getBlockByNumber($blockID);

// 根据交易哈希查询信息
// 根据交易哈希返回交易的收据
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->getTransactionReceipt($txHash);
$bep20->getTransactionReceipt($txHash);

// 根据交易哈希返回关于所请求交易的信息
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->getTransactionByHash($txHash);
$bep20->getTransactionByHash($txHash);

// 根据交易哈希查询交易状态
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->receiptStatus($txHash);
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Support Binance's BNB and BEP20, which include functions such as address creatio
- Transaction transfer (offline signature) `transfer(string $from, string $to, float $amount)`
- Query the latest block `blockNumber()`
- Query information according to the blockchain `getBlockByNumber(int $blockID)`
- *Query information based on transaction hash `getTransactionReceipt(string $txHash)`
- Returns the receipt of a transaction by transaction hash `getTransactionReceipt(string $txHash)`
- *Returns the information about a transaction requested by transaction hash `getTransactionByHash(string $txHash)`
- *Query transaction status based on transaction hash `receiptStatus(string $txHash)`


Expand Down Expand Up @@ -111,11 +112,16 @@ $blockID = 24631027;
$bnb->getBlockByNumber($blockID);
$bep20->getBlockByNumber($blockID);

// Query information based on transaction hash
// Returns the receipt of a transaction by transaction hash
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->getTransactionReceipt($txHash);
$bep20->getTransactionReceipt($txHash);

// Returns the information about a transaction requested by transaction hash
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->getTransactionByHash($txHash);
$bep20->getTransactionByHash($txHash);

// Query transaction status based on transaction hash
$txHash = '0x4dd20d01af4c621d2fc293dff17a8fd8403ea3577988bfb245a18bfb6f50604b';
$bnb->receiptStatus($txHash);
Expand Down
5 changes: 5 additions & 0 deletions src/BscscanApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function getTransactionReceipt(string $txHash)
return $res;
}

function getTransactionByHash(string $txHash)
{
return $this->send('eth_getTransactionByHash', ['txHash' => $txHash]);
}

function sendRawTransaction($raw)
{
return $this->send('eth_sendRawTransaction', ['hex' => $raw]);
Expand Down
5 changes: 5 additions & 0 deletions src/NodeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ function getTransactionReceipt(string $txHash)
return $this->send('eth_getTransactionReceipt', ['txHash' => $txHash]);
}

function getTransactionByHash(string $txHash)
{
return $this->send('eth_getTransactionByHash', ['txHash' => $txHash]);
}

function getNetwork(): string
{
return $this->network;
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function receiptStatus(string $txHash): ?bool;

function getTransactionReceipt(string $txHash);

function getTransactionByHash(string $txHash);

function sendRawTransaction($raw);

function getNonce(string $address);
Expand Down

0 comments on commit b6d72bb

Please sign in to comment.