iexbase / tron-api-python

A Python API for interacting with Tron (TRX)
https://tronapi-for-python.readthedocs.io
MIT License
165 stars 84 forks source link

Still receiving revert error #33

Open ShilazTech opened 5 years ago

ShilazTech commented 5 years ago

Hello serderovsh,

I upgraded all the installations including tronapi but I still see the same problem. That transactions are being reverted. pls see latest as done just now {'ret': [{'contractRet': 'REVERT'}], 'signature': ['8e7742b4ad0645f53a5c8002edd5460d86b1e194741a661651f0b63fec994c6f2bc8fb7c24be18b68958786874086a01a46ef56ece9aadb19bdf621c3c2b495c1c'], 'txID': 'a8091842b1a0c7eeca9c41f9579669ab2e7ee5901ba6e0d6d635d40ffffb3565', 'raw_data': {'contract': [{'parameter': {'value': {'data': '16bd160c00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000', 'owner_address': '419e737d5db19beafc2a9a813211cc73add2d3a872', 'contract_address': '412ec5f63da00583085d4c2c5e8ec3c8d17bde5e28', 'call_value': 10000000}, 'type_url': 'type.googleapis.com/protocol.TriggerSmartContract'}, 'type': 'TriggerSmartContract'}], 'ref_block_bytes': '4bc6', 'ref_block_hash': '3ef538e20d4c9c06', 'expiration': 1548241557000, 'fee_limit': 600000, 'timestamp': 1548241501491}}

could you please check to do it with tronbet or dice. I am getting this error for both of them I tried.

I appreciate all the help you provide.

Thanks and Regards,

serderovsh commented 5 years ago

send the sample code again

ShilazTech commented 5 years ago

Hello serderovsh

Below is my key code

fee_limit =600000 multplier =1000000 bet_value=10*multplier direction=0 rollvalue=50 x=1 if x==1: ##for tronbet parameters=[{'type': 'uint256', 'value': rollvalue}, {'type': 'uint256', 'value': direction}] parameters=[{"value":rollvalue,"type":"uint256"},{"value":direction,"type":"uint256"}] tx=tron.transaction_builder.trigger_smart_contract('TEEXEWrkMFKapSMJ6mErg39ELFKDqEs6w3','GoodLuck',fee_limit,bet_value,parameters)

tx=tx['transaction']
#print(tx)
tx=tron.trx.sign(tx)#,True)
tron.trx.broadcast(tx)

if x==0: #for dice add='TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk' parameters=[{"name":"_addr","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_index","type":"uint256"}] parameters=[{"value":add,"type":"address"},{"value":rollvalue,"type":"uint256"},{"value":direction,"type":"uint256"}] tx=tron.transaction_builder.trigger_smart_contract('TMYcx6eoRXnePKT1jVn25ZNeMNJ6828HWk','Bet',fee_limit,bet_value,parameters) tx=tx['transaction'] tx=tron.trx.sign(tx)#,True) tron.trx.broadcast(tx)

mytxID=tx["txID"] time.sleep(10) result = tron.trx.get_transaction(mytxID) print(result)

serderovsh commented 5 years ago

Your code is weird.

Try using a similar algorithm.

tx = tron.transaction_builder.trigger_smart_contract(
contract_address=,
function_selector=,
fee_limit=,
call_value=,
parameters=[]
)

New options for tokens https://github.com/iexbase/tron-api-python/blob/master/tronapi/transactionbuilder.py#L535 https://github.com/iexbase/tron-api-python/blob/master/tronapi/transactionbuilder.py#L536

Get transaction details using: https://github.com/iexbase/tron-api-python/blob/master/tronapi/trx.py#L119

tron.trx.sign(tx)#,True) -> tron.trx.sign(tx)

ShilazTech commented 5 years ago

Hello serdervosh,

I gave the code exactly as you suggested but I still get revert. below is my code

fee_limit =600000 multplier =1000000 bet_value=10*multplier direction=0 rollvalue=50 x=1 if x==1: ##for tronbet parameters=[{"value":rollvalue,"type":"uint256"},{"value":direction,"type":"uint256"}] tx = tron.transaction_builder.trigger_smart_contract( contract_address='TEEXEWrkMFKapSMJ6mErg39ELFKDqEs6w3', function_selector='GoodLuck', fee_limit=fee_limit, call_value=bet_value, parameters=parameters )

and below is my corresponding rever message for trx

{'ret': [{'contractRet': 'REVERT'}], 'signature': ['fe460fdf511cc9f5fb7c9adbc94244a551f03cc81ee4f88cfdea1c00629b3ae33858ae1ce78e50962fa113ad407eff750c93496fad3d3b8ca162fec9e66f08f51b'], 'txID': 'bbb6471303a242dbddd42490e5cfd427e974a65120edacaf5ee5bc96a453df4e', 'raw_data': {'contract': [{'parameter': {'value': {'data': '16bd160c00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000', 'owner_address': '419e737d5db19beafc2a9a813211cc73add2d3a872', 'contract_address': '412ec5f63da00583085d4c2c5e8ec3c8d17bde5e28', 'call_value': 10000000}, 'type_url': 'type.googleapis.com/protocol.TriggerSmartContract'}, 'type': 'TriggerSmartContract'}], 'ref_block_bytes': 'f325', 'ref_block_hash': '2c525217f5cce69b', 'expiration': 1549160655000, 'fee_limit': 600000, 'timestamp': 1549160597325}}

could you please help me on this

netman2048 commented 5 years ago

@ShilazTech did you ever figure this out? I when I look at my transaction, it is calling the function correct but neither parameter is getting passed to the function. It has to be something with how the parameter variable is structured. I've tried many different things and nothing seems to work.

netman2048 commented 5 years ago

@ShilazTech for what it's worth, I got it to work... sort of. Getting a message complaining about being out of energy even though I have energy. This is what I used:

dice_contract = "TWmhXhXjgXTj87trBufmWFuXtQP8sCWZZV" owner_addr = "OMITTED" good_luck_func = "GoodLuck(uint256,uint256)" parameters=[{"type":"uint256","value":4},{"type":"uint256","value":1}] fee_limit = tron.toSun(0.0035) call_value = tron.toSun(10) tx = tron.transaction_builder.trigger_smart_contract(contract_address=dice_contract, function_selector=good_luck_func, parameters=parameters, fee_limit=fee_limit, call_value=call_value, owner_address=owner_addr) stx = tron.trx.sign(tx['transaction']) tron.trx.broadcast(stx)

netman2048 commented 5 years ago

Figured out the energy problem too. I raised my fee limit from 0.0035 to 0.2 and it went through. Only problem is that how do you figure out if your roll won or not in case you want to change you bet for the next roll.