Conversion_Kitchen_Code/kitchen_counter/Blockchain2/transferMatic.py

34 lines
1.2 KiB
Python
Executable File

# from web3 import Web3
# from MNF.settings import PRIVATE_KEY,ACCOUNT
# from .blockchainsetting import OWNER_KEY
# web3 = Web3(Web3.HTTPProvider('https://rpc-mumbai.maticvigil.com/'))
# if web3.isConnected():
# print("Connected to Matic TestNet")
# else:
# print("Failed to connect to Matic TestNet")
# private_key = OWNER_KEY
def maticTransfer(recipient_address):
# sender_address = ACCOUNT
# account = web3.eth.account.privateKeyToAccount(private_key)
# recipient_address = recipient_address
# amount_to_send = Web3.toWei(0.01, 'ether')
# transaction = {
# 'from': sender_address,
# 'to': recipient_address,
# 'value': amount_to_send,
# 'gas': 2000000,
# 'gasPrice': web3.toWei('5', 'gwei'),
# 'nonce': web3.eth.getTransactionCount(sender_address),
# 'chainId': 80001
# }
# signed_tx = web3.eth.account.sign_transaction(transaction, private_key=private_key)
# tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
# tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)
# if tx_receipt.status == 1:
# print("Transaction successful!")
# else:
# print("Transaction failed.")
print("Transaction successful!")