Zecale - Reconciling Privacy and Scalability on Smart-Contract Chains  0.5
Reference implementation of the Zecale protocol by Clearmatics
zecale_deploy.py
Go to the documentation of this file.
1 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 #
3 # SPDX-License-Identifier: LGPL-3.0+
4 
5 from zecale.cli.defaults import AGGREGATOR_VERIFICATION_KEY_FILE_DEFAULT
6 from zecale.cli.command_context import CommandContext
7 from zecale.cli.utils import load_verification_key
8 from zecale.core.dispatcher_contract import DispatcherContract
9 from click import command, option, Context, pass_context
10 import json
11 
12 
13 @command()
14 @option(
15  "--verification-key-file", "-f",
16  default=AGGREGATOR_VERIFICATION_KEY_FILE_DEFAULT,
17  help="Aggregator verification key file (default: "
18  f"{AGGREGATOR_VERIFICATION_KEY_FILE_DEFAULT})")
19 @pass_context
20 def deploy(
21  ctx: Context,
22  verification_key_file: str) -> None:
23  """
24  Deploy the zecale dispatcher contract.
25  """
26 
27  cmd_ctx: CommandContext = ctx.obj
28  aggregator_config = cmd_ctx.get_aggregator_configuration()
29  snark = aggregator_config.wrapper_snark
30  pp = aggregator_config.wrapper_pairing_parameters
31  (eth_addr, eth_private_key) = cmd_ctx.get_eth_key_and_address()
32 
33  # Load verification key
34  vk = load_verification_key(snark, verification_key_file)
35 
36  # Deploy contract, passing the encoded key to the constructor
37  web3 = cmd_ctx.get_web3()
38  _dispatcher, dispatcher_instance = DispatcherContract.deploy(
39  web3, snark, pp, vk, eth_addr, eth_private_key)
40 
41  # Save the contract instance description
42  with open(cmd_ctx.instance_file, "w") as instance_f:
43  json.dump(dispatcher_instance.to_json_dict(), instance_f)
zecale.cli.utils
Definition: utils.py:1
zecale.cli.defaults
Definition: defaults.py:1
zecale.cli.utils.load_verification_key
IVerificationKey load_verification_key(IZKSnarkProvider zksnark, str vk_file)
Definition: utils.py:11
zecale.cli.zecale_deploy.deploy
None deploy(Context ctx, str verification_key_file)
Definition: zecale_deploy.py:20
zecale.cli.command_context
Definition: command_context.py:1
zecale.core.dispatcher_contract
Definition: dispatcher_contract.py:1