Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Functions | Variables
test_commands.deploy_test_token Namespace Reference

Functions

None deploy_test_token (Optional[str] eth_network, Optional[str] eth_addr, Optional[str] eth_private_key, int mint_amount, str recipient_address)
 
Interface compile_token ()
 
Any deploy_token (Any web3, str deployer_address, Optional[bytes] deployer_private_key, Optional[int] deployment_gas)
 
bytes mint_token (Any web3, Any token_instance, str spender_address, str deployer_address, Optional[bytes] deployer_private_key, EtherValue token_amount)
 

Variables

 help
 
 default
 
 type
 

Function Documentation

◆ compile_token()

Interface test_commands.deploy_test_token.compile_token ( )
Compile the testing ERC20 token contract

Definition at line 60 of file deploy_test_token.py.

60 def compile_token() -> Interface:
61  """
62  Compile the testing ERC20 token contract
63  """
64 
65  zeth_dir = get_zeth_dir()
66  allowed_path = join(
67  zeth_dir,
68  "zeth_contracts/contracts")
69  path_to_token = join(
70  zeth_dir,
71  "zeth_contracts/contracts",
72  "ERC20Mintable.sol")
73  # Compilation
74  set_solc_version(SOL_COMPILER_VERSION)
75  compiled_sol = compile_files([path_to_token], allow_paths=allowed_path)
76  token_interface = compiled_sol[path_to_token + ":ERC20Mintable"]
77  return token_interface
78 
79 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deploy_test_token()

None test_commands.deploy_test_token.deploy_test_token ( Optional[str]  eth_network,
Optional[str]  eth_addr,
Optional[str]  eth_private_key,
int  mint_amount,
str  recipient_address 
)
Deploy a simple ERC20 token for testing, and mint some for a specific
address. Print the token address.

Definition at line 31 of file deploy_test_token.py.

32  eth_network: Optional[str],
33  eth_addr: Optional[str],
34  eth_private_key: Optional[str],
35  mint_amount: int,
36  recipient_address: str) -> None:
37  """
38  Deploy a simple ERC20 token for testing, and mint some for a specific
39  address. Print the token address.
40  """
41  eth_addr = load_eth_address(eth_addr)
42  eth_private_key_data = load_eth_private_key(eth_private_key)
43  recipient_address = load_eth_address(recipient_address)
44  web3 = open_web3_from_network(get_eth_network(eth_network))
45  token_instance = deploy_token(
46  web3, eth_addr, eth_private_key_data, 4000000) \
47  # pylint: disable=no-member
48  mint_tx_hash = mint_token(
49  web3,
50  token_instance,
51  recipient_address,
52  eth_addr,
53  eth_private_key_data,
54  EtherValue(mint_amount, 'ether'))
55  web3.eth.waitForTransactionReceipt(mint_tx_hash) # pylint: disable=no-member
56 
57  print(token_instance.address)
58 
59 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deploy_token()

Any test_commands.deploy_test_token.deploy_token ( Any  web3,
str  deployer_address,
Optional[bytes]  deployer_private_key,
Optional[int]  deployment_gas 
)
Deploy the testing ERC20 token contract

Definition at line 80 of file deploy_test_token.py.

80 def deploy_token(
81  web3: Any,
82  deployer_address: str,
83  deployer_private_key: Optional[bytes],
84  deployment_gas: Optional[int]) -> Any:
85  """
86  Deploy the testing ERC20 token contract
87  """
88  token_interface = compile_token()
89  token = web3.eth.contract(
90  abi=token_interface['abi'], bytecode=token_interface['bin'])
91  constructor_call = token.constructor()
92  tx_hash = send_contract_call(
93  web3=web3,
94  call=constructor_call,
95  sender_eth_addr=deployer_address,
96  sender_eth_private_key=deployer_private_key,
97  value=None,
98  gas=deployment_gas)
99  tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
100 
101  token = web3.eth.contract(
102  address=tx_receipt.contractAddress,
103  abi=token_interface['abi'],
104  )
105  return token
106 
107 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mint_token()

bytes test_commands.deploy_test_token.mint_token ( Any  web3,
Any  token_instance,
str  spender_address,
str  deployer_address,
Optional[bytes]  deployer_private_key,
EtherValue  token_amount 
)

Definition at line 108 of file deploy_test_token.py.

108 def mint_token(
109  web3: Any,
110  token_instance: Any,
111  spender_address: str,
112  deployer_address: str,
113  deployer_private_key: Optional[bytes],
114  token_amount: EtherValue) -> bytes:
115  mint_call = token_instance.functions.mint(spender_address, token_amount.wei)
116  return send_contract_call(
117  web3=web3,
118  call=mint_call,
119  sender_eth_addr=deployer_address,
120  sender_eth_private_key=deployer_private_key)
121 
122 
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ default

test_commands.deploy_test_token.default

Definition at line 25 of file deploy_test_token.py.

◆ help

test_commands.deploy_test_token.help

Definition at line 21 of file deploy_test_token.py.

◆ type

test_commands.deploy_test_token.type

Definition at line 29 of file deploy_test_token.py.

zeth.cli.utils.get_eth_network
NetworkConfig get_eth_network(Optional[str] eth_network)
Definition: utils.py:84
test_commands.deploy_test_token.compile_token
Interface compile_token()
Definition: deploy_test_token.py:60
zeth.cli.utils.load_eth_address
str load_eth_address(Optional[str] eth_addr)
Definition: utils.py:444
zeth.core.utils.get_zeth_dir
str get_zeth_dir()
Definition: utils.py:249
test_commands.deploy_test_token.mint_token
bytes mint_token(Any web3, Any token_instance, str spender_address, str deployer_address, Optional[bytes] deployer_private_key, EtherValue token_amount)
Definition: deploy_test_token.py:108
test_commands.deploy_test_token.deploy_token
Any deploy_token(Any web3, str deployer_address, Optional[bytes] deployer_private_key, Optional[int] deployment_gas)
Definition: deploy_test_token.py:80
zeth.core.contracts.compile_files
Any compile_files(List[str] files, **Any kwargs)
Definition: contracts.py:122
zeth.cli.utils.load_eth_private_key
Optional[bytes] load_eth_private_key(Optional[str] private_key_file)
Definition: utils.py:465
zeth.cli.utils.open_web3_from_network
Any open_web3_from_network(NetworkConfig eth_net)
Definition: utils.py:114
zeth.core.contracts.send_contract_call
bytes send_contract_call(Any web3, Any call, str sender_eth_addr, Optional[bytes] sender_eth_private_key=None, Optional[EtherValue] value=None, Optional[int] gas=None)
Definition: contracts.py:131
test_commands.deploy_test_token.deploy_test_token
None deploy_test_token(Optional[str] eth_network, Optional[str] eth_addr, Optional[str] eth_private_key, int mint_amount, str recipient_address)
Definition: deploy_test_token.py:31