Giter VIP home page Giter VIP logo

Comments (7)

serderovsh avatar serderovsh commented on June 19, 2024

send the sample code again

from tron-api-python.

ShilazTech avatar ShilazTech commented on June 19, 2024

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)

from tron-api-python.

serderovsh avatar serderovsh commented on June 19, 2024

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)

from tron-api-python.

ShilazTech avatar ShilazTech commented on June 19, 2024

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

from tron-api-python.

netman2048 avatar netman2048 commented on June 19, 2024

@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.

from tron-api-python.

netman2048 avatar netman2048 commented on June 19, 2024

@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)

from tron-api-python.

netman2048 avatar netman2048 commented on June 19, 2024

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.

from tron-api-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.