Skip to content

[zksync2==0.6.0] <use python sdk to listen contract event error> #80

Closed Answered by danijelTxFusion
rnsKelvin asked this question in SDKs
Discussion options

You must be logged in to vote

The solution that @equalogix proposed works on zkSync Era correctly because that part is compatible with Web3.py. zksync2 SDK can be used in the same way. Here is the example on how to filter Transfer event on ETH_TOKEN smart contract on L2.

zk_web3 = ZkSyncBuilder.build("https://zksync2-testnet.zksync.dev")
zk_web3.middleware_onion.inject(geth_poa_middleware, layer=0)
zk_web3.middleware_onion.add(local_filter_middleware)

filter_dict = {
    "address": [zk_web3.to_checksum_address(L2_ETH_TOKEN_ADDRESS)],
    "topics": [
        zk_web3.keccak(text="Transfer(address,address,uint256)").hex(),
    ],
}
filter_obj = zk_web3.zksync.filter(filter_dict)
for i in range(5):
    time.sleep(10)  # …

Replies: 11 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@rnsKelvin
Comment options

@dutterbutter
Comment options

Comment options

You must be logged in to vote
2 replies
@rnsKelvin
Comment options

@rnsKelvin
Comment options

Comment options

You must be logged in to vote
5 replies
@rnsKelvin
Comment options

@equalogix
Comment options

@rnsKelvin
Comment options

@equalogix
Comment options

@rnsKelvin
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by idea404

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
SDKs
Labels
sdk Questions for the SDKs
10 participants