Skip to content

Commit

Permalink
get block number from tx hash
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang committed Oct 23, 2023
1 parent 432e18d commit 1f3edbf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/apis/web3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,17 @@ def get_transaction(self, tx_hash: str) -> Optional[TxData]:
transaction = None

return transaction


def get_tx_block_number(self, tx_hash: str) -> Optional[int]:
"""
Takes tx hash as input, returns block number where tx took place.
"""
transaction = self.get_transaction(tx_hash)
if transaction is None:
return None
else:
return transaction['blockNumber']

def get_receipt(self, tx_hash: str) -> Optional[TxReceipt]:
"""
Get the receipt of a transaction from the transaction hash.
Expand Down

0 comments on commit 1f3edbf

Please sign in to comment.