Skip to content

Commit

Permalink
update: fetch nonce before sending txn and use nonce in txn to avoid …
Browse files Browse the repository at this point in the history
…situation where nonce is not up to speed
  • Loading branch information
riccardo-gnosis committed Sep 9, 2024
1 parent c7a61ce commit 5d20283
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions api/api/services/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,26 @@ def claim_native(w3, sender, recipient, amount):
- recipient: String
- amount: integer in wei format
"""

nonce = w3.eth.get_transaction_count(sender)

tx_dict = {
'from': sender,
'to': recipient,
'value': amount
'value': amount,
'nonce': nonce
}
return w3.eth.send_transaction(tx_dict).hex()

tx_hash = w3.eth.send_transaction(tx_dict).hex()

# this may cause a timeout, keep here for testing purposes
# receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
# if receipt.status == 1:
# print(f"transaction successful {tx_hash}")
# else:
# print(f"transaction failed {tx_hash}")

return tx_hash


def claim_token(w3, sender, recipient, amount, token_address):
Expand Down

0 comments on commit 5d20283

Please sign in to comment.