@@ -49,25 +49,46 @@ custom_json = {"x": 35, "y": 70, "color": "#e50000"}
4949viz.custom(protocol, custom_json, None , required_regular_auths)
5050```
5151
52- ### Get account with custom protocol and latest block
52+ ### Get data from custom protocol
5353
5454``` python
5555from viz import Client
5656from viz.account import Account
5757from viz.block import Block
5858from viz.instance import set_shared_blockchain_instance
59+ import json
5960
6061viz = Client(" wss://node.viz.cx/ws" )
6162set_shared_blockchain_instance(viz)
6263
64+ account_name = " id"
6365protocol = " V"
64- account = Account(" id" , viz, protocol)
66+ account = Account(account_name, protocol = protocol)
67+
6568counter_inside_protocol = account[" custom_sequence" ]
6669last_used_in_block = account[" custom_sequence_block_num" ]
70+
6771block = Block(last_used_in_block)
72+
73+ for tx in block[" transactions" ]:
74+ for op_type, op_data in tx[" operations" ]:
75+ if op_type != " custom" :
76+ continue
77+ if op_data.get(" id" ) != protocol:
78+ continue
79+ if account_name not in op_data.get(" required_regular_auths" , []):
80+ continue
81+
82+ raw_json = op_data.get(" json" )
83+ try :
84+ json_from_protocol = json.loads(raw_json) if raw_json else None
85+ except json.JSONDecodeError:
86+ json_from_protocol = None
87+
88+ print (json_from_protocol)
6889```
6990
70- Any direct RPC call:
91+ ### Any direct RPC call
7192
7293``` python
7394from viz import Client
0 commit comments