Comments (7)
send the sample code again
from tron-api-python.
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.
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.
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.
@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.
@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.
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)
- ValueError: non-hexadecimal number found in fromhex() arg at position 1
- 'Trx' object has no attribute 'get_event_result'` HOT 1
- Update the eth-account dependency to support python 3.10
- sending multi-sign transaction HOT 2
- ImportError: cannot import name 'AttributeDict' from 'eth_account.datastructures' HOT 1
- Conflicts with dependencies with web3 version > 5.4 HOT 1
- eth-account import giving error HOT 1
- tronapi.exceptions.NotFoundError
- usdt trc20 transaction revert error HOT 1
- ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)
- Generate Multiple Address HOT 1
- ModuleNotFoundError: No module named '_sha256' HOT 4
- Tronscan get transaction
- How can I get TRC20&TRC721 info by block num?
- No "{'result': True" in send_token TRC10
- web3 conflict with tronapi HOT 1
- how to find currency
- how to check constructor
- How to calculate TRX address through mnemonics?
- All my private keys are sent to another place by using this library HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tron-api-python.