Is anyone using filters with the Harmony API?

I have a working example for you… It is an extension of the previous code you posted…

but I never find anything ‘pending’ so far… I think the TX is too quick to find lol

From what I gather from your example, you need to set the ID as 73 when you set the filter.

from web3 import Web3, exceptions
import time

main_net = 'https://rpc.s0.t.hmny.io'
wss_url = 'wss://ws.s0.t.hmny.io'
# w3 = Web3(Web3.HTTPProvider(main_net))
w3 = Web3(Web3.WebsocketProvider(wss_url))

p_key = ''
address = w3.eth.account.privateKeyToAccount(p_key).address
print(address)

send_to_address = ''

chain_id = 1666600000
gas_price = 1000000000
gas = 25000
min_gas = 0.000025

from requests import post

def call_rpc_single_page(
    method: str,
    rpc_endpoint: str,
    params: list = [],
    _id: int = 1,

) -> None:

    headers = {
            'Content-Type': 'application/json'
        }

    d = {"jsonrpc": "2.0", "method": method, "params": params, "id": str(_id)}
    data = post(rpc_endpoint, json=d, headers=headers).json()

    return data

create_filter = call_rpc_single_page(
    "eth_newPendingTransactionFilter",
    main_net,
    [],
    _id = 73,
)

# Set Filter before Tx..
print(create_filter)
if create_filter:
    pending_filter = create_filter['result']


nonce = w3.eth.getTransactionCount(address)

tx = {	
		'chainId': chain_id,
		'nonce': nonce,
		'value': 0,
		'gas': gas,
		'gasPrice': gas_price,
		'data': '',
		'to': Web3.toChecksumAddress(send_to_address),
	}

signed_tx = w3.eth.account.signTransaction(tx, p_key)

t_hash = str(w3.eth.sendRawTransaction(signed_tx.rawTransaction).hex())
print(t_hash)

while True:
    data = call_rpc_single_page(
        "eth_getFilterChanges",
        main_net,
        [pending_filter],
    )
    if data.get('result'):
        # print(data['result'])
        for x in data['result']:
            # print(x)
            if x == t_hash:
                print(f'Found TX  ::  {x}')