# TransactionReceiptData

交易回执数据结构。

## 字段说明

| 字段                           | 类型                           | 说明                  |
| ---------------------------- | ---------------------------- | ------------------- |
| transaction\_hash            | HexBytes                     | 交易哈希                |
| block\_number                | BlockNumber                  | 区块高度                |
| transaction\_index           | int                          | 交易在区块中的索引           |
| transaction\_status          | int                          | 交易状态(1 成功,0 失败)     |
| transaction\_type            | int                          | 交易类型                |
| action                       | str                          | 交易动作类型              |
| sender                       | ChecksumAddress              | 发送者地址               |
| to                           | ChecksumAddress              | 接收者地址               |
| nonce                        | Nonce                        | 交易序号                |
| value                        | Wei                          | 转账金额                |
| gas\_used                    | int                          | 实际使用的 Gas           |
| gas\_limit                   | int                          | Gas 上限              |
| gas\_price                   | Optional\[Wei]               | Gas 价格              |
| max\_fee\_per\_gas           | Optional\[Wei]               | 最大 Gas 费用(EIP-1559) |
| max\_priority\_fee\_per\_gas | Optional\[Wei]               | 最大优先费用(EIP-1559)    |
| effective\_gas\_price        | Optional\[Wei]               | 实际 Gas 价格           |
| contract\_address            | Optional\[ChecksumAddress]   | 部署的合约地址(仅合约创建交易)    |
| contract                     | Optional\[Any]               | 合约实例(仅合约创建交易)       |
| logs                         | Optional\[List\[LogReceipt]] | 交易日志                |
| input\_data                  | HexBytes                     | 交易输入数据              |
| r                            | HexBytes                     | 签名 r 值              |
| s                            | HexBytes                     | 签名 s 值              |
| v                            | HexBytes                     | 签名 v 值              |

## 示例代码

```python
# 获取交易回执
receipt: TransactionReceiptData = chain.get_transaction_receipt_by_hash("0x...")

if receipt.transaction_status:
    print(f"Transaction successful: {receipt.transaction_hash.hex()}")
    print(f"Block Number: {receipt.block_number}")
    print(f"From: {receipt.sender}")
    print(f"To: {receipt.to}")
    print(f"Value: {Web3.from_wei(receipt.value, 'ether')} ETH")
    print(f"Gas Used: {receipt.gas_used}")

    if receipt.contract_address:
        print(f"Deployed Contract: {receipt.contract_address}")
```
