Im trying to get the blockstamp for the most recent transaction

im trying to use a end pint to get blockstamp time on most recent transaction but i cant get it work this is my codeapi_key =

Get the time of the last transaction for the token_address

            params = {
                "chain": "eth",
                "contract_addresses": [token_address],
                "exclude_contracts": {},
                "wallet_addresses": [],
                "exclude_wallets": [],
                "limit": 1
            }

            params_tuple = tuple(params.items())

            result = evm_api.token.get_erc20_transfers(
            api_key=api_key,
            params=params_tuple,
        )   
        print(f"Token Transfers Results: {result}")
        if result and "result" in result and len(result["result"]) > 0:
                last_transaction_time = parse(result["result"][0]["block_timestamp"])
                last_transaction_time = last_transaction_time.astimezone(timezone.utc).replace(tzinfo=None)

        # Print the timestamp
                print(f"Last Transaction Timestamp: {last_transaction_time}")

        # Check if the last transaction was more than 3 days ago
                if (datetime.utcnow() - last_transaction_time).days > 3:
                    print("Skipping this token as the last transaction was more than 3 days ago.")
                    continue

        time.sleep(1 / 50)

Check if the last transaction was more than 3 days ago

        if last_transaction_time and (datetime.utcnow() - last_transaction_time).days > 3:
            continue

Hey @michael123434,

Thanks for reaching out to us :grinning_face_with_smiling_eyes:

Do you get any error from the code that you run?

Also, I recommend that you email us at [email protected] as your API key is now compromised and therefore unsecure.

No error handlers are registered, logging exception.
Traceback (most recent call last):
File “c:\Users\micha\newwally3\env\Lib\site-packages\telegram\ext\dispatcher.py”, line 555, in process_update
handler.handle_update(update, self, check, context)
File “c:\Users\micha\newwally3\env\Lib\site-packages\telegram\ext\handler.py”, line 198, in handle_update
return self.callback(update, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Users\micha\newwally3\env\wally3.py”, line 404, in wallet_handler
asyncio.run(wallet(update, context, wallet_address, chat_id))
File “C:\Program Files\Python311\Lib\asyncio\runners.py”, line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return future.result()
^^^^^^^^^^^^^^^
File “c:\Users\micha\newwally3\env\wally3.py”, line 500, in wallet
await process_transaction_actions(chat_id, update.message.message_id)
File “c:\Users\micha\newwally3\env\wally3.py”, line 241, in process_transaction_actions
result = evm_api.token.get_erc20_transfers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\Users\micha\newwally3\env\Lib\site-packages\moralis\evm_api\token\get_erc20_transfers.py”, line 17, in get_erc20_transfers
query_params: typing.Any = {k: v for k, v in params.items() if k in RequestQueryParams.annotations.keys()}
^^^^^^^^^^^^

Hey @michael123434,

I noticed that you added this line right here to turn params into a tuple.

params_tuple = tuple(params.items())

Our SDK does not accept this type format, instead you should keep the param as it is and make it params=params when calling the Moralis function.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.