9 get_eth_network, load_eth_address, EtherValue, open_web3_from_network, \
11 from click
import command, option, pass_context, argument, ClickException, Context
12 from typing
import Optional
14 FUND_AMOUNT_DEFAULT = 1000000
20 help=f
"Source address or filename (default: {ETH_ADDRESS_DEFAULT})")
23 help=f
"Source private key file (default: {ETH_PRIVATE_KEY_FILE_DEFAULT})")
27 default=FUND_AMOUNT_DEFAULT,
28 help=f
"Amount to fund in Ether (default: {FUND_AMOUNT_DEFAULT})")
29 @argument(
"dest-addr")
34 eth_private_key: Optional[str],
35 eth_addr: Optional[str],
38 Send Ether from the local eth-addr to a destination address.
46 if eth_private_key_data
is None:
47 raise ClickException(
"hosted accounts are not supported")
49 print(f
"eth_addr = {eth_addr}")
50 print(f
"dest_addr = {dest_addr}")
51 print(f
"amount = {amount}")
58 "gasPrice": web3.eth.gasPrice,
59 "nonce": web3.eth.getTransactionCount(eth_addr)
61 send_tx_desc[
"gas"] = web3.eth.estimateGas(send_tx_desc)
63 signed_tx = web3.eth.account.signTransaction(
64 send_tx_desc, eth_private_key_data)
66 tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)