Skip to main content

Tracking deposits

After everything is ready, you can implement deposit tracking.

For that, iterate through all transactions in each block to search for payment_receiver_inc operation with an address matching the address in which you are interested:

def deposit_flow(deposit_address):
# some logic we want to execute on deposit
def on_deposit(deposit):
print(json.dumps(deposit, indent=2))

latest_block = network_status()["current_block_identifier"]["index"]
while True:
# check if transactions to the deposit address are present in the latest block
txs = wait_for_block(latest_block)['block']['transactions']
deposits = []
for tx in txs:
for op in tx["operations"]:
if op["account"]["address"] == deposit_address \
and op["type"] == "payment_receiver_inc":
deposits.append({
"tx_hash": tx["transaction_identifier"]["hash"],
"amount": op["amount"]["value"]
})

# process deposits
for d in deposits:
on_deposit(d)

latest_block += 1