> For the complete documentation index, see [llms.txt](https://poseidon.seaeye.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://poseidon.seaeye.cn/evm/chain/get_transaction_receipt_by_block_id_and_index.md).

# get\_transaction\_receipt\_by\_block\_id\_and\_index

根据区块 ID 和索引来获取该交易的回执信息。

## 方法定义

```python
def get_transaction_receipt_by_block_id_and_index(self, block_id: BlockIdentifier, transaction_index: int) -> Optional[TransactionReceiptData]
```

## 参数说明

| 参数                 | 类型              | 说明                        |
| ------------------ | --------------- | ------------------------- |
| block\_id          | BlockIdentifier | 区块 ID(区块号/区块哈希/'latest'等) |
| transaction\_index | int             | 交易在区块中的索引                 |

## 返回值

返回 TransactionReceiptData 对象,字段说明与 get\_transaction\_receipt\_by\_hash 相同。

## 示例代码

```python
# 获取最新区块的第一笔交易
receipt = chain.get_transaction_receipt_by_block_id_and_index("latest", 0)
if receipt:
    print(f"Transaction Hash: {receipt.transaction_hash.hex()}")
    print(f"From: {receipt.sender}")
    print(f"To: {receipt.to}")
    print(f"Value: {Web3.from_wei(receipt.value, 'ether')} ETH")
```
