Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Functions | Variables
zeth.helper.eth_fund Namespace Reference

Functions

None eth_fund (Context ctx, Optional[str] eth_addr, Optional[str] source_addr, int amount)
 

Variables

int FUND_AMOUNT_DEFAULT = 1000000
 
 help
 
 type
 
 default
 

Function Documentation

◆ eth_fund()

None zeth.helper.eth_fund.eth_fund ( Context  ctx,
Optional[str]  eth_addr,
Optional[str]  source_addr,
int  amount 
)
Fund an address. If no source address is given, the first hosted account on
the RPC host is used. This command should only be used in test environments
such as ganache or autonity-helloworld.

Definition at line 26 of file eth_fund.py.

26 def eth_fund(
27  ctx: Context,
28  eth_addr: Optional[str],
29  source_addr: Optional[str],
30  amount: int) -> None:
31  """
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.
35  """
36  eth_addr = load_eth_address(eth_addr)
37  eth_network = get_eth_network(ctx.obj["eth_network"])
38  web3 = open_web3_from_network(eth_network)
39 
40  if not source_addr:
41  # Use the first hosted address.
42  source_addr = web3.eth.accounts[0] # pylint: disable=no-member
43 
44  if eth_network.name == "autonity-helloworld":
45  # The Autonity helloworld network supplies hosted accounts, secured
46  # with the password 'test'. Attempt to unlock it.
47  # pylint: disable=import-outside-toplevel, no-member
48  from web3.middleware import geth_poa_middleware # type: ignore
49  web3.middleware_onion.inject(geth_poa_middleware, layer=0)
50  web3.personal.unlockAccount(source_addr, "test")
51 
52  source_addr = load_eth_address(source_addr)
53  print(f"eth_addr = {eth_addr}")
54  print(f"source_addr = {source_addr}")
55  print(f"amount = {amount}")
56 
57  web3.eth.sendTransaction({ # pylint: disable=no-member
58  "from": source_addr,
59  "to": eth_addr,
60  "value": EtherValue(amount).wei
61  })
Here is the call graph for this function:

Variable Documentation

◆ default

zeth.helper.eth_fund.default

Definition at line 23 of file eth_fund.py.

◆ FUND_AMOUNT_DEFAULT

int zeth.helper.eth_fund.FUND_AMOUNT_DEFAULT = 1000000

Definition at line 12 of file eth_fund.py.

◆ help

zeth.helper.eth_fund.help

Definition at line 18 of file eth_fund.py.

◆ type

zeth.helper.eth_fund.type

Definition at line 22 of file eth_fund.py.

zeth.cli.utils.get_eth_network
NetworkConfig get_eth_network(Optional[str] eth_network)
Definition: utils.py:84
zeth.cli.utils.load_eth_address
str load_eth_address(Optional[str] eth_addr)
Definition: utils.py:444
zeth.helper.eth_fund.eth_fund
None eth_fund(Context ctx, Optional[str] eth_addr, Optional[str] source_addr, int amount)
Definition: eth_fund.py:26
zeth.cli.utils.open_web3_from_network
Any open_web3_from_network(NetworkConfig eth_net)
Definition: utils.py:114