I want to send a token by this (tron-api-python) library but I received an error When I send the Trx, there is no problem and it is sent, but when I want to send the desired token using the smart contract, I get an error.
from tronapi import Tron
from tronapi import HttpProvider
full_node = HttpProvider('https://nile.trongrid.io')
solidity_node = HttpProvider('https://nile.trongrid.io')
event_server = HttpProvider('https://nile.trongrid.io')
tron = Tron(full_node=full_node,
solidity_node=solidity_node,
event_server=event_server)
trx_kwargs = dict()
trx_kwargs["private_key"] = '59d4b72df50290d7f78e2c16fc27758d6e235f3959f2212f2497fc55da33e888'
trx_kwargs["default_address"] = 'TRNDt7bjFoTq7p52iw5u2BLNhsff1ux7Fc'
trron = Tron(**trx_kwargs)
kwargs = dict()
kwargs["contract_address"] = tron.address.to_hex("TLBaRhANQoJFTqre9Nf1mjuwNWjCJeYqUL") # USDT contract address
kwargs["function_selector"] = "transfer(address,uint256)" # function to call and types. for reference on tronscan it looks like this: transfer(address _to,uint256 _value)
kwargs["fee_limit"] = 5000000 # fee limit in tron (5 TRX here)
kwargs["call_value"] = 0 # I have no idea
Towallet = 'TTG8u8fUKqJwMtB59ppaWqgFVGDb5ojWPU'
Amount = 10.3
# added message
send = trron.trx.send_transaction(trron.address.to_hex(Towallet), Amount)
txid = send["txid"]
print(send)
print(f'your txid is {txid}')
I get this error Validate TransferContract error, no OwnerAccount.
full error:
Traceback (most recent call last):
File "main.py", line 26, in <module>
send = trron.trx.send_transaction(trron.address.to_hex(Towallet), Amount)
File "/home/runner/newtrx/venv/lib/python3.8/site-packages/tronapi/trx.py", line 421, in send_transaction
tx = self.tron.transaction_builder.send_transaction(
File "/home/runner/newtrx/venv/lib/python3.8/site-packages/tronapi/transactionbuilder.py", line 68, in send_transaction
response = self.tron.manager.request('/wallet/createtransaction', {
File "/home/runner/newtrx/venv/lib/python3.8/site-packages/tronapi/manager.py", line 124, in request
return self.full_node.request(url, json=params, method=method)
File "/home/runner/newtrx/venv/lib/python3.8/site-packages/tronapi/providers/http.py", line 84, in request
response = self._request(
File "/home/runner/newtrx/venv/lib/python3.8/site-packages/tronapi/providers/http.py", line 133, in _request
raise ValueError(data['Error'])
ValueError: class org.tron.core.exception.ContractValidateException : Validate TransferContract error, no OwnerAccount.