6 from zeth.core.contracts
import InstanceDescription
7 from zeth.cli.utils
import open_web3_from_network
9 from click
import command, argument, option, pass_context, Context, ClickException
10 from typing
import Optional
14 @argument(
"scalar", type=int)
17 default=APPLICATION_INSTANCE_FILE_DEFAULT,
18 help=
"File to write instance information to")
20 "--check", type=int, help=
"Check the result against the given value")
26 check: Optional[int]) ->
None:
28 Query the deployed contract to find the value stored for a given scalar.
29 (These values are the parameters submitted along side the proof for the
33 eth_network = ctx.obj[
"eth_network"]
36 with open(instance_file,
"r")
as instance_f:
37 instance_desc = InstanceDescription.from_json_dict(json.load(instance_f))
40 web3 = open_web3_from_network(eth_network)
41 app_contract = instance_desc.instantiate(web3)
42 result: int = app_contract.functions.get(scalar).call()
43 print(f
"{scalar}: {result}")
45 if (check
is not None)
and (result != check):
46 raise ClickException(
"state check failed")