I just wanted to know how I can adapt this code from sending eth to sending MATIC on the Polygon Network. Thanks for the help.....Cheers
import os
#Get the hgtps endpoint for the polygon network and create web3 object
w3 = Web3(Web3.HTTPProvider
('https://polygon-mainnet.infura.io/v3/5ba943bce7ef47a9bd791767ee5ce3d5'))
#Test if it works
#x = w3.isConnected()
#print(x)
# Set up the addresses to send from and to
public_address = ''
receiver_address = ''
priv_key = os.getenv('PRIVATE_KEY')
# Convert to checksumadress (not to loose bites when sending)
sender1 = Web3.toChecksumAddress(public_address)
receiver1 = Web3.toChecksumAddress(receiver_address)
# Set up the nonce
nonce = w3.eth.getTransactionCount(sender1)
# Set up the transaction
tx = {'nonce': nonce,
'to': receiver1,
'value' w3.toWei(1, eth),
'gas': 21000,
'gasPrice': w3.toWei(50, gwei)
}
signed_tx = w3.eth.account.signTransaction(tx, priv_key)
tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
print(web3.toHex(tx_hash)) ```