-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_eth.py
More file actions
70 lines (49 loc) · 1.41 KB
/
Copy pathsend_eth.py
File metadata and controls
70 lines (49 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# send_eth.py
from web3 import Web3
# ======================================
# RPC
# ======================================
RPC_URL = "https://ethereum-holesky-rpc.publicnode.com"
w3 = Web3(Web3.HTTPProvider(RPC_URL))
# ======================================
# WALLET CONFIG
# ======================================
private_key = "AIzaSyDO_WlJ7nHoe7T6udRU_wHO-TaW_LcZlTc"
account = w3.eth.account.from_key(private_key)
sender = account.address
receiver = "0xd8519a8b8825aa0dcc73aad572f447fae102fe88"
# ======================================
# AMOUNT
# ======================================
amount_eth = 9.9
# ======================================
# NONCE
# ======================================
nonce = w3.eth.get_transaction_count(sender)
# ======================================
# TRANSACTION
# ======================================
tx = {
"nonce": nonce,
"to": receiver,
"value": w3.to_wei(amount_eth, "ether"),
"gas": 21000,
"gasPrice": w3.eth.gas_price,
"chainId": 17000 # Holesky
}
# ======================================
# SIGN
# ======================================
signed_tx = w3.eth.account.sign_transaction(
tx,
private_key
)
# ======================================
# SEND
# ======================================
tx_hash = w3.eth.send_raw_transaction(
signed_tx.raw_transaction
)
print("TX HASH:")
print(w3.to_hex(tx_hash))
print("SUCCESS SEND", amount_eth, "ETH")