I'm trying to trigger buyEnergy on this contract TEeLFcbSc2LFSFrTZnWRCacZzo3ZtBybh2
buyEnergy function accept 5 parameters
buyEnergy(address _receiver, uint8 _energyRentalUnit, uint256 _energyAmount, uint256 affiliate, uint256 _rentalPeriod)
I have a problem getting it to work, it is always failing Failed Transaction can be found here: https://tronscan.org/#/transaction/dd4663d0abe81b52b58dcd53d1ba56c8cc95d72c85a5619dccfac14cb07e4b29
Example of transaction that was sucess https://tronscan.org/#/transaction/3507297e4de1fe5d713d7d87826a6d7fde648bb9cad7d70200d31378fa48bb42
I used Tronpy python library to create this transaction, here is my code Can anyone find what im doing wrong in my Code? I believe it is with the type of the parameters
from tronpy import Tron
from tronpy.keys import PrivateKey
mainWalletPrivateKey = '*********************************'
mainWalletAddress = 'TH***'
priv_key = PrivateKey.fromhex(mainWalletPrivateKey)
client = Tron()
receiver_address = client.to_hex_address(mainWalletAddress)
cntr = client.get_contract("TEeLFcbSc2LFSFrTZnWRCacZzo3ZtBybh2")
print('Available Energy:', cntr.functions.getAvailableEnergy()/1000000)
price = cntr.functions.calculatePrice(1, 100000, 1)[0]
print('Price:', cntr.functions.calculatePrice(1, 100000, 1)[0])
buyEnergy = cntr.functions.buyEnergy.with_transfer(price).call(receiver_address, 1, 65000, 0, 1).with_owner(mainWalletAddress).fee_limit(5_000_000).build().sign(priv_key)
print(buyEnergy.broadcast())