7 get_eth_network, load_eth_address, EtherValue, open_web3_from_network
8 from click
import command, option, pass_context, Context
9 from typing
import Optional
12 FUND_AMOUNT_DEFAULT = 1000000
18 help=f
"Address or address filename (default: {ETH_ADDRESS_DEFAULT})")
19 @option(
"--source-addr", help=
"Address or address filename (optional)")
23 default=FUND_AMOUNT_DEFAULT,
24 help=f
"Amount to fund (default: {FUND_AMOUNT_DEFAULT})")
28 eth_addr: Optional[str],
29 source_addr: Optional[str],
32 Fund an address. If no source address is given, the first hosted account on
33 the RPC host is used. This command should only be used in test environments
34 such as ganache or autonity-helloworld.
42 source_addr = web3.eth.accounts[0]
44 if eth_network.name ==
"autonity-helloworld":
48 from web3.middleware
import geth_poa_middleware
49 web3.middleware_onion.inject(geth_poa_middleware, layer=0)
50 web3.personal.unlockAccount(source_addr,
"test")
53 print(f
"eth_addr = {eth_addr}")
54 print(f
"source_addr = {source_addr}")
55 print(f
"amount = {amount}")
57 web3.eth.sendTransaction({