MCPcopy
hub / github.com/raiden-network/raiden / main

Function main

tools/transfer_eth.py:21–56  ·  view source on GitHub ↗
(keystore_file, password, rpc_url, eth_amount, targets_file)

Source from the content-addressed store, hash-verified

19@click.argument("eth-amount", type=int)
20@click.argument("targets_file", type=click.File())
21def main(keystore_file, password, rpc_url, eth_amount, targets_file) -> None:
22 web3 = Web3(HTTPProvider(rpc_url))
23 with open(keystore_file, "r") as keystore:
24 account = Account(json.load(keystore), password, keystore_file)
25
26 assert account.privkey, "Could not decode keystore file: wrong password"
27 assert account.address, "Could not decode keystore file: no 'address' field found"
28 print("Using account:", to_checksum_address(account.address))
29
30 client = JSONRPCClient(
31 web3, account.privkey, block_num_confirmations=DEFAULT_NUMBER_OF_BLOCK_CONFIRMATIONS
32 )
33
34 targets = [t.strip() for t in targets_file]
35 balance = client.balance(client.address)
36
37 balance_needed = len(targets) * eth_amount
38 if balance_needed * WEI_TO_ETH > balance:
39 print(
40 "Not enough balance to fund {} accounts with {} eth each. Need {}, have {}".format(
41 len(targets), eth_amount, balance_needed, balance / WEI_TO_ETH
42 )
43 )
44
45 print("Sending {} eth to:".format(eth_amount))
46
47 for target in targets:
48 print(" - {}".format(target))
49 gas_price = web3.eth.gasPrice # pylint: disable=no-member
50 client.transact(
51 EthTransfer(
52 to_address=to_canonical_address(target),
53 value=eth_amount * WEI_TO_ETH,
54 gas_price=gas_price,
55 )
56 )
57
58
59if __name__ == "__main__":

Callers 1

transfer_eth.pyFile · 0.70

Calls 6

balanceMethod · 0.95
transactMethod · 0.95
AccountClass · 0.90
to_checksum_addressFunction · 0.90
JSONRPCClientClass · 0.90
EthTransferClass · 0.90

Tested by

no test coverage detected