Closed afshinita closed 6 months ago
async def send_trc20(self, private_key, sender_address, receiver_address, amount_as_usdt): try: provider = HTTPProvider(api_key=self.trongrid_api_key) client = Tron(provider=provider) contract = client.get_contract(CONFIG_MODEL.tron.trc20_contract_address) # USDT contract address pv_key = PrivateKey(bytes.fromhex(private_key)) amount = trx_to_sun( amount_as_usdt) # Prepare real usdt(Tronpy needs USDT like this) LIKE SUN -> * 1_000_000 txn = ( contract.functions.transfer(receiver_address, amount) .with_owner(sender_address) # public address of the (private key) .fee_limit(trx_to_sun(self.estimate_fee())) .build() .sign(pv_key) ) tx_id = txn.txid result = txn.broadcast().wait() return tx_id, result except Exception as e: print(e) return None, None
self.trongrid_api_key ein chi hast error mide dadash
CONFIG_MODEL has error trx_to_sun has error it is not defined
The docs have enough of examples