-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
51 lines (40 loc) · 1.55 KB
/
Main.py
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
from web3 import Web3
from eth_abi import encode
import random
import time
from BridgeAbi import scroll_bridge_abi
from Config import (
private_key,
bridge_addres_contract,
GETH_address_contract,
SCROLL_RPC,
GOERLI_RPC
)
web3 = Web3(Web3.HTTPProvider(GOERLI_RPC))
print(f'Connection is: {web3.is_connected}')
address = Web3.to_checksum_address(web3.eth.account.from_key(private_key=private_key).address)
def scroll_bridge():
# Bridge contract from Goerli -> Scroll
scroll_bridge_contract = web3.to_checksum_address(bridge_addres_contract)
bridge_contrat_scroll = web3.eth.contract(scroll_bridge_contract, abi=scroll_bridge_abi)
GETH = int(web3.to_wei(0.01, 'ether'))
gasPrice = int(web3.eth.gas_price * 1.1)
bridge_transaction = bridge_contrat_scroll.functions.depositETH(
10000000000000000,
40000,
).build_transaction({
'nonce': web3.eth.get_transaction_count(address),
'gas': web3.eth.gas_price,
'gasPrice': gasPrice,
'from': address,
'value': web3.to_wei(0.01, 'ether'),
})
time.sleep(3)
print('Start TX')
sign_transaction = web3.eth.account.sign_transaction(bridge_transaction, private_key)
transaction_hash = web3.eth.send_raw_transaction(sign_transaction.rawTransaction).hex()
# send_transaction = web3.eth.send_raw_transaction(sign_transaction.rawTransaction)
# tx = web3.eth.wait_for_transaction_receipt(send_transaction)
print(f'Bridge Done from Goerli -> Scroll with HASH {transaction_hash}')
scroll_bridge()
print('end')