8 from zeth.cli.utils import load_eth_address, load_eth_private_key, \
9 get_eth_network, open_web3_from_network
11 ETH_NETWORK_FILE_DEFAULT, ETH_NETWORK_DEFAULT
12 from click
import command, argument, option
13 from os.path
import join
14 from solcx
import compile_files, set_solc_version
15 from typing
import Optional, Any
21 help=f
"Address or address filename (default: {ETH_ADDRESS_DEFAULT})")
22 @option(
"--eth-private-key", help=
"Sender's eth private key file")
26 help=
"Ethereum RPC endpoint, network or config file "
27 f
"(default: '{ETH_NETWORK_FILE_DEFAULT}' if it exists, otherwise "
28 f
"'{ETH_NETWORK_DEFAULT}')")
29 @argument(
"mint_amount", type=int)
30 @argument(
"recipient_address")
32 eth_network: Optional[str],
33 eth_addr: Optional[str],
34 eth_private_key: Optional[str],
36 recipient_address: str) ->
None:
38 Deploy a simple ERC20 token for testing, and mint some for a specific
39 address. Print the token address.
46 web3, eth_addr, eth_private_key_data, 4000000) \
55 web3.eth.waitForTransactionReceipt(mint_tx_hash)
57 print(token_instance.address)
62 Compile the testing ERC20 token contract
68 "zeth_contracts/contracts")
71 "zeth_contracts/contracts",
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
82 deployer_address: str,
83 deployer_private_key: Optional[bytes],
84 deployment_gas: Optional[int]) -> Any:
86 Deploy the testing ERC20 token contract
89 token = web3.eth.contract(
90 abi=token_interface[
'abi'], bytecode=token_interface[
'bin'])
91 constructor_call = token.constructor()
94 call=constructor_call,
95 sender_eth_addr=deployer_address,
96 sender_eth_private_key=deployer_private_key,
99 tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
101 token = web3.eth.contract(
102 address=tx_receipt.contractAddress,
103 abi=token_interface[
'abi'],
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)
119 sender_eth_addr=deployer_address,
120 sender_eth_private_key=deployer_private_key)
123 if __name__ ==
"__main__":