Tron contract validate error

CONTRACT_VALIDATE_ERROR when running migrate #8 Comments Getting this error when running tronbox migrate —reset The text was updated successfully, but these errors were encountered: This seems to have been an issue in tronbox and was resolved when I updated it to the latest (currently 2.2.2) So the issue is still present if it uses […]

Содержание

  1. CONTRACT_VALIDATE_ERROR when running migrate #8
  2. Comments
  3. TriggerConstantContract via gRPC not working. #3602
  4. Comments
  5. Can not deploy after upgrade to 2.2.0 #33
  6. Comments
  7. CONTRACT_VALIDATE_ERROR about tron-box HOT 2 CLOSED
  8. Comments (2)
  9. Related Issues (20)
  10. Recommend Projects
  11. React
  12. Vue.js
  13. Typescript
  14. TensorFlow
  15. Django
  16. Laravel
  17. Recommend Topics
  18. javascript
  19. server
  20. Machine learning
  21. Visualization
  22. Recommend Org
  23. Facebook
  24. Microsoft
  25. How to calculate energy consumption of sending TRC20 Token? #2982
  26. Comments

CONTRACT_VALIDATE_ERROR when running migrate #8

Getting this error when running tronbox migrate —reset

The text was updated successfully, but these errors were encountered:

This seems to have been an issue in tronbox and was resolved when I updated it to the latest (currently 2.2.2)

So the issue is still present if it uses the shasta network. It works fine with the development network.

tronbox migrate —reset —network development works fine
but tronbox migrate —reset —network shasta gives the contract validation error.

Since migrate-and-setup.sh uses the shasta network the npm run setup-dapp command fails unless you change the sh script to use the develompent network. It seems that all the code is supposed to use the development network anyway so maybe this just needs to be updated.

Side note, on Windows 10 you have to install the windows-build-tools npm package for this project:
npm install -g —production windows-build-tools

I guess you are running latest TronBox 2.2.2.
When someone can deploy on Tron Quickstart but cannot deploy on Shasta, usually, means that they don’t have enough energy in the Shasta account. Can you verify that?

Ahh. that must be it. I have TRX but no energy. Thanks, I’ll try that.

I guess you are running latest TronBox 2.2.2.
When someone can deploy on Tron Quickstart but cannot deploy on Shasta, usually, means that they don’t have enough energy in the Shasta account. Can you verify that?

Yes, that was the issue. It’s working now, thank you! Is there a chat room somewhere to ask things like how this project is configured and how it works, etc? Basically, general TRON dev questions. I don’t think they’d be appropriate here.

Источник

TriggerConstantContract via gRPC not working. #3602

I am trying to execute TriggerConstantContract via gRPC protocol and having returned this error:

«A���=contract validate error: No contract or not a smart contract

I am setting addresses like this:

gRPC client is PHP library generated from this repo, but I think that’s irrelevant.
I am using the latest stable release.

I have TriggerConstantContract working via HTTP but can’t make it working using gRPC.

Problem is caused because of this part of framework/src/main/java/org/tron/core/Wallet.java
public Transaction triggerConstantContract

to be more specific:

I am getting this error even with provided USDT contract at this format: 419E62BE7F4F103C36507CB2A753418791B1CDC182

Is there a bug or I am passing invalid variables? I am just trying to call USDT TRC20 contract and call function name()

The text was updated successfully, but these errors were encountered:

Have you checked if you are in the correct network? These addresses work only in Shasta test net.

I am using my own node and doing it all via 127.0.0.1 My node is generated from data from https://backup.trongrid.io/ and syncing with the main network.
I have this main config supportConstant = true

I am using the latest release and even tried to compile from the latest source from the main brench.

I just don’t understand what I am doing wrong. When using HTTP API I can query my contract, but when try the same via gRPC I have that error: «No contract or not a smart contract».

I only have a problem calling triggerConstantContract, other endpoints are working both in HTTP and gRPC.

I am thinking should I maybe again deploy my contract to my local node and see if then it will exist, but that just doesn’t make sense to me, because it works via HTTP.

I’ve said that the addresses you provided are from Shasta test net but not the main net.
USDT address on main net is :
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t — Base58
41A614F803B6FD780986A42C78EC9C7F77E6DED13C — Hex

Ok, that was just a bad example I provided.

I have now tried with usdt contract address and owner like this:

My node is synced 1 second ago with the main network, but still, I have this returned: «No contract or not a smart contract»
Via HTTP the same example is working.

I have even changed and recompiled FullNode to see if the address is passed properly and I can see there in java exception that it’s received as «41a614f803b6fd780986a42c78ec9c7f77e6ded13c», but still node thin fails with «No contract or not a smart contract».

I am so desperate to solve this, but can’t figure out what is wrong. Thanks for helping.

Alright, in the Protobuf definition that addresses are in the type of bytes . You may try to find out the corresponding data type in your language and set the param again.

Well, this is how gRPC library was generated for my programming language (PHP):

So it’s expected to have a string as input for address, and validation exist for that.

Also, I have checked what is received on the server-side in FullNode and it was byte type that I had to convert to string in JAVA in order to see if the proper value was passed.

So I think that server receive byte format of hex address, but for some reason it trow exception with message that it’s not an existing contract even for USDT contract in synced and up to date node.

Источник

Can not deploy after upgrade to 2.2.0 #33

2.1.10 has problem «CONTRACT_VALIDATE_ERROR» #32
try to upgrade to 2.2.0, but it still doesn’t work.

The text was updated successfully, but these errors were encountered:

ha lol, thought it was just me! neither, all kaputt

There was a critical error in the previous version.
We just published TronBox 2.0.1, which supports the new java-tron 3.2 and fixes a couple of issues. Can you update and try again, please?

@GarryPlays This should be fixed. Reopen it, please, if not.

still doesn’t work even for test «Metacoin» project. nothing was changed. i’m using tronbox v 2.3.0

Using network ‘shasta’.

Running migration: 1_initial_migration.js
Deploying Migrations.
ERROR: Unknown error: <
«code»: «CONTRACT_VALIDATE_ERROR»,
«message»: «636f6e74726163742076616c6964617465206572726f72203a206163636f756e74206e6f7420657869737473»
>

That message is contract validate error : account not exists .
With TronBox 2.3.0, when there is an error during the deployment, you should see the link to get info about the transaction. Did you check it?

BTW, metacoin-box passes all the tests on Shasta without issue (I can share a video, if you don’t believe me).
Is it possible that the account that you are using doesn’t have enough energy or bandwidth?

I would side with sullof here. I had the same issue, but since shasta recently reset, your account will most likely not have any tron in it.
Of course with shasta refill being down since 2 days it seems mission impossible to refill your account 😀
Or I am just hitting every single maintenance window they have.
Feel free to send me some shasta tron if you have TU1TYKYNKE928LvmXSSR7iiShr3SjexomY

Источник

CONTRACT_VALIDATE_ERROR about tron-box HOT 2 CLOSED

There was a critical error in the previous version.
We just published TronBox 2.0.1, which supports the new java-tron 3.2 and fixes a couple of issues. Can you update and try again, please?

sullof commented on January 16, 2023

@shapowang This should be fixed in TronBox 2.2.1.
Reopen this issue, please, if not.

  • Compile command error HOT 9
  • tronbox migrate error HOT 7
  • deploy error HOT 2
  • When TRC10 support? HOT 2
  • tronbox version; tronbox compile Invalid member of stdlib error HOT 1
  • Tronbox migrate error — cannot connect to TronWeb HOT 3
  • Can’t deploy a contract to development network HOT 4
  • Can’t even get tronbox in terminal HOT 1
  • tronbox migrate —reset —network shasta msg killed HOT 3
  • tronbox init FAILS on Windows 10 HOT 3
  • Cannot test sending TRX to contract method HOT 2
  • ERROR: NOT_ENOUGH_EFFECTIVE_CONNECTION (effective connection:0 lt minEffectiveConnection:1) while broadcasting the transaction to create the contract Migrations HOT 2
  • tronbox.js can’t compile? HOT 1
  • «PayloadTooLargeError: request entity too large» when run «tronbox test» HOT 2
  • Smart Contract deployed on testnet shasta not getting searched.
  • OUT_OF_ENERGY HOT 2
  • npm WARN tarball tarball data for [email protected] (sha512-hv4iQVmxUvhVkzfJc5YOew7aV0dJ+oE531hf+FLnvDs7CliP2T9gSoaM2xuKvbT7tVUJu0oGuQya/+gKaAnXCQ==) seems to be corrupted. Trying one more time. HOT 1
  • Contract function call return txID instead of value HOT 1
  • Will someone please explain this to me? HOT 1
  • cannot compile and migrate HOT 1

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

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

Recommend Topics

javascript

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

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

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.

Источник

How to calculate energy consumption of sending TRC20 Token? #2982

I’m a developer from Bitpie Wallet. When sending USDT (TRC20), if there is not enough energy or TRON, this transaction will fail. I didn’t find a way to estimate the energy that will be consumed by a transaction before sending it.

For users to have a better experience using TRON, we want to show users the bandwidth, energy and TRON needed before sending the transaction. So that users won’t send transactions that will fail.

Can you provide a method to calculate energy consumption?

The text was updated successfully, but these errors were encountered:

same question .
Looking forward to the solution

I’m a developer from Bitpie Wallet. When sending USDT (TRC20), if there is not enough energy or TRON, this transaction will fail. I didn’t find a way to estimate the energy that will be consumed by a transaction before sending it.

For users to have a better experience using TRON, we want to show users the bandwidth, energy and TRON needed before sending the transaction. So that users won’t send transactions that will fail.

Can you provide a method to calculate energy consumption?

If these docs do not help you, please let me know.

Hi Tron,
I’m a developer from Bitpie Wallet. When sending USDT (TRC20), if there is not enough energy or TRON, this transaction will fail. I didn’t find a way to estimate the energy that will be consumed by a transaction before sending it.
For users to have a better experience using TRON, we want to show users the bandwidth, energy and TRON needed before sending the transaction. So that users won’t send transactions that will fail.
Can you provide a method to calculate energy consumption?

If these docs do not help you, please let me know.

This doc didn’t solve my problem, I still don’t know how to calculate the energy consumption by a transaction before sending it.

Hi Tron,
I’m a developer from Bitpie Wallet. When sending USDT (TRC20), if there is not enough energy or TRON, this transaction will fail. I didn’t find a way to estimate the energy that will be consumed by a transaction before sending it.
For users to have a better experience using TRON, we want to show users the bandwidth, energy and TRON needed before sending the transaction. So that users won’t send transactions that will fail.
Can you provide a method to calculate energy consumption?

You can check this doc: https://developers.tron.network/docs/resource-model
If these docs do not help you, please let me know.

This doc didn’t solve my problem, I still don’t know how to calculate the energy consumption by a transaction before sending it.

I think we can get how to calculate Bandwidth for a transaction and how to get user’s bandwidth and energy from the doc above,
Actually, you can consider that USDT20 is a smart contract on java-tron, the calculation method is the same as that of other smart contracts.
So in my opinion, the energy of transfer USDT is at a fixed cost, you can have a test to see whether it is right.
The above is for reference only.

I am also consulting the members of the community, I believe they will show a correct answer later, please be patient.

Источник

CONTRACT_VALIDATE_ERROR when running migrate #8

Comments

vicpon commented Dec 8, 2018 •

Getting this error when running tronbox migrate —reset

The text was updated successfully, but these errors were encountered:

vicpon commented Dec 8, 2018

This seems to have been an issue in tronbox and was resolved when I updated it to the latest (currently 2.2.2)

vicpon commented Dec 8, 2018

So the issue is still present if it uses the shasta network. It works fine with the development network.

tronbox migrate —reset —network development works fine
but tronbox migrate —reset —network shasta gives the contract validation error.

Since migrate-and-setup.sh uses the shasta network the npm run setup-dapp command fails unless you change the sh script to use the develompent network. It seems that all the code is supposed to use the development network anyway so maybe this just needs to be updated.

Side note, on Windows 10 you have to install the windows-build-tools npm package for this project:
npm install -g —production windows-build-tools

sullof commented Dec 8, 2018

I guess you are running latest TronBox 2.2.2.
When someone can deploy on Tron Quickstart but cannot deploy on Shasta, usually, means that they don’t have enough energy in the Shasta account. Can you verify that?

vicpon commented Dec 9, 2018

Ahh. that must be it. I have TRX but no energy. Thanks, I’ll try that.

vicpon commented Dec 9, 2018

I guess you are running latest TronBox 2.2.2.
When someone can deploy on Tron Quickstart but cannot deploy on Shasta, usually, means that they don’t have enough energy in the Shasta account. Can you verify that?

Yes, that was the issue. It’s working now, thank you! Is there a chat room somewhere to ask things like how this project is configured and how it works, etc? Basically, general TRON dev questions. I don’t think they’d be appropriate here.

Источник

TriggerConstantContract via gRPC not working. #3602

Comments

neshala commented Dec 26, 2020 •

I am trying to execute TriggerConstantContract via gRPC protocol and having returned this error:

«A���=contract validate error: No contract or not a smart contract

I am setting addresses like this:

gRPC client is PHP library generated from this repo, but I think that’s irrelevant.
I am using the latest stable release.

I have TriggerConstantContract working via HTTP but can’t make it working using gRPC.

Problem is caused because of this part of framework/src/main/java/org/tron/core/Wallet.java
public Transaction triggerConstantContract

to be more specific:

I am getting this error even with provided USDT contract at this format: 419E62BE7F4F103C36507CB2A753418791B1CDC182

Is there a bug or I am passing invalid variables? I am just trying to call USDT TRC20 contract and call function name()

The text was updated successfully, but these errors were encountered:

Starsakary commented Dec 28, 2020

Have you checked if you are in the correct network? These addresses work only in Shasta test net.

neshala commented Dec 28, 2020 •

I am using my own node and doing it all via 127.0.0.1 My node is generated from data from https://backup.trongrid.io/ and syncing with the main network.
I have this main config supportConstant = true

I am using the latest release and even tried to compile from the latest source from the main brench.

I just don’t understand what I am doing wrong. When using HTTP API I can query my contract, but when try the same via gRPC I have that error: «No contract or not a smart contract».

I only have a problem calling triggerConstantContract, other endpoints are working both in HTTP and gRPC.

I am thinking should I maybe again deploy my contract to my local node and see if then it will exist, but that just doesn’t make sense to me, because it works via HTTP.

Starsakary commented Dec 28, 2020

I’ve said that the addresses you provided are from Shasta test net but not the main net.
USDT address on main net is :
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t — Base58
41A614F803B6FD780986A42C78EC9C7F77E6DED13C — Hex

neshala commented Dec 28, 2020 •

Ok, that was just a bad example I provided.

I have now tried with usdt contract address and owner like this:

My node is synced 1 second ago with the main network, but still, I have this returned: «No contract or not a smart contract»
Via HTTP the same example is working.

I have even changed and recompiled FullNode to see if the address is passed properly and I can see there in java exception that it’s received as «41a614f803b6fd780986a42c78ec9c7f77e6ded13c», but still node thin fails with «No contract or not a smart contract».

I am so desperate to solve this, but can’t figure out what is wrong. Thanks for helping.

Starsakary commented Dec 28, 2020 •

Alright, in the Protobuf definition that addresses are in the type of bytes . You may try to find out the corresponding data type in your language and set the param again.

neshala commented Dec 28, 2020

Well, this is how gRPC library was generated for my programming language (PHP):

So it’s expected to have a string as input for address, and validation exist for that.

Also, I have checked what is received on the server-side in FullNode and it was byte type that I had to convert to string in JAVA in order to see if the proper value was passed.

So I think that server receive byte format of hex address, but for some reason it trow exception with message that it’s not an existing contract even for USDT contract in synced and up to date node.

Источник

Can not deploy after upgrade to 2.2.0 #33

Comments

emn178 commented Dec 4, 2018 •

2.1.10 has problem «CONTRACT_VALIDATE_ERROR» #32
try to upgrade to 2.2.0, but it still doesn’t work.

The text was updated successfully, but these errors were encountered:

GarryPlays commented Dec 4, 2018

ha lol, thought it was just me! neither, all kaputt

sullof commented Dec 4, 2018

There was a critical error in the previous version.
We just published TronBox 2.0.1, which supports the new java-tron 3.2 and fixes a couple of issues. Can you update and try again, please?

sullof commented Dec 5, 2018

@GarryPlays This should be fixed. Reopen it, please, if not.

infine8 commented Dec 15, 2018 •

still doesn’t work even for test «Metacoin» project. nothing was changed. i’m using tronbox v 2.3.0

Using network ‘shasta’.

Running migration: 1_initial_migration.js
Deploying Migrations.
ERROR: Unknown error: <
«code»: «CONTRACT_VALIDATE_ERROR»,
«message»: «636f6e74726163742076616c6964617465206572726f72203a206163636f756e74206e6f7420657869737473»
>

sullof commented Dec 15, 2018

That message is contract validate error : account not exists .
With TronBox 2.3.0, when there is an error during the deployment, you should see the link to get info about the transaction. Did you check it?

sullof commented Dec 15, 2018

BTW, metacoin-box passes all the tests on Shasta without issue (I can share a video, if you don’t believe me).
Is it possible that the account that you are using doesn’t have enough energy or bandwidth?

GarryPlays commented Dec 15, 2018 •

I would side with sullof here. I had the same issue, but since shasta recently reset, your account will most likely not have any tron in it.
Of course with shasta refill being down since 2 days it seems mission impossible to refill your account 😀
Or I am just hitting every single maintenance window they have.
Feel free to send me some shasta tron if you have TU1TYKYNKE928LvmXSSR7iiShr3SjexomY

Источник

DoctorLai/Tron-FAQ

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Tron Blockchain FAQs

  1. What will be the consumption token when users don’t have enough bandwidth to make transfer transaction?

It will burn TRX to pay the fee, one bandwidth = 420 SUN (previously was 140 SUN before Proposal 51), you can calculate based on this. 1TRX = 1000000SUN. You can check this doc for more tech detail https://developers.tron.network/docs/resource-model

  1. Is there a config in tron full node which can allow only certain ip’s or ip range to query http api?

This needs to be restricted in the nginx service.

  1. We are trying to set up a multisignature with 7 participants, but it isn’t allowing us more than 5 users. The documentation says that the maximum is 8 active accesses.

8 Active Accesses meaning that you can set up to 8 permission groups. In each group, max num of participants is 5 i.e. so the maximum number of participants in a multisignature is 5.

  1. How to verify Tron Wallet Addresses offline?
  1. How to get the Fee by Transaction Hash?

You can use the TronGrid API GetTransactionInfoById to Query the transaction fee, block height by transaction id see: https://developers.tron.network/reference#walletgettransactionbyid

  1. How to transfer trc20 token to smart contact?

See https://developers.tron.network/docs/trc20-contract-interaction Be careful on transfer TRC20 to a contract address. In most case, transfer TRC20 token to a contract means you will lose those tokens becase no one can withdraw it.

Just receiving a token into your wallet does not have any harm to your wallet, but using that token on any platform is solely your responsibility, don’t do anything with an unknown token. Tron network is a decentralised system anyone in the world can create a token with any name and distribute it over tron network to any wallets, there is no permission is needed for incoming transfer, also tronlink is a decentralised wallet no permission is needed for incoming transfer, if someone sends this token to your wallet most probably it will visible. Verified or legitimate token has a blue tick ✔️ mark. You can hide the visibility of the token by using the «+» option on the right side of the tronlink home page. Also, you can see more information for that token by clicking the information button on the top right corner of that token’s transfer history page. If by mistake you have tried to swap fake tokens on any scam website then please don’t use that wallet again immediately transfer your wallet funds to a new wallet.

  1. How do I retrieve transaction note from the get_tranaction() function?

Please refer to https://developers.tron.network/docs/make-transaction-locally and after you get the transaction by id, please parse the data field to get the note.

  1. If I want to become an SR(c), would I have to deploy a fullnode?

Yes, because if your node goes up the list, it must be able to create blocks and confirm transactions.

  1. I have created a token on your blockchain network but it’s price is not yet determined. What should I do for the price to appear in my wallet?

It needs to be listed on PoloniDex or another exchange & tracked by CoinGecko. If you need the price to show, then exchange listing is needed, again if not on PoloniDEX, then the exchange you list it on must be tracked by CoinGecko and you must apply for your token to be tracked by CoinGecko.

  1. Can I use Ethereum private key to generate a Tron address?
  1. How to figure out gas costs when deploying smart contracts on my tronbox setup? I can then use that account to query «http://127.0.0.1:9090/wallet/getcontract?value=xxx» and get JSON that describes the methods available in the contract, but I see not cost for the creation or running of the contract when I interact with it.

You need the transaction hash to query it and see how much it has used. Besides the more functions and internal transactions a contract has the more processing power it uses on the node hence the fee going up.

  1. Can I use Tron from my Shasta testnet to invest into something?

TRX on shasta can only work on shasta, mainly for Developers, no other value.

  1. What is the cost to deploy a new contract?

Deploy a new contract is not free, for a simple TRC20 Token contract, it will cost around 80 TRX to complete it. it will cost more if your contract is more complex.

  1. I want to deploy a contract in tron blockchain. Can I use the tron energy for it instead of paying TRX?

Trx are burned only if you don’t have enough energy or bandwidth.

  1. What is the justswap contract address on shasta?

Justswap does not have a testnet version.

  1. Is there a way to accept a particular token as payment in a contract? Ethereum has a ERC-1363 Payable Token — is there something comparable for TRON?

I would suggest you try on Tron testnet, it should be supported from TVM level.

  1. When a token is made Do users always have to pay a fee for the transfer? Is there a solution for transferring tokens free of charge?

You can freeze TRX to get ressources for free transfer.

  1. How do we use TRON-PRO-API-KEY in the website?

when you send API make sure you include the key in the headers for example

  1. How can i use api to create wallet address for my app users?

It is suggested that you generate address offline instead of using any API.

  1. Is it possible to get jst token on Shasta test net? I wanted to test the justlink vrf but I using shasta instead of nile?

users cannot join shasta, but you can join Nile and get JST token at: https://nileex.io/join/getJoinPage

  1. When i create an adress, next how i make it to online chain?

Activate that account, for example transfer 1 TRX to that account.

  1. Will it be any case, energy of an wallet can be negative value?

energy = obtain-consumed, and let’s say now you have 200k obtianed by freezing from two different account, one 150k, one 50k, and you consumed 100k, but the one freezing 150k do a unfreez, and this time, the consumed is more than obtained, so an energy can be negative. I would say it is normal if your energy is negative after unfreeze, and all your consumed energy will be recovered to 0 in 24 hours.

  1. Even you are not producing block, you still need to keep running the server and all the txn consume storage, right ?

Yes it consumes storage because you are keeping a copy of the blockchain, also if your node is voted up and activates as a top SR it has to be in sync or may be kicked back down or even voted out of the SRs.

  1. Although TRON is burning on a daily basis, why is the supply increasing?

TRON burns and produces at the same time. If the production rate is high compared to burning, of course, the percentage of currencies will rise and vice versa.

  1. What is the formula for energy regeneration?

regeneration is 24 hours, it may be per second. I do not have the exact formula but is something like ((ENERGY_Assigned / 86400 seconds) * (timestamp — last_consume_timestamp) + ENERGY_left_calculation_formula_at_last_consume_timestamp[This is a separate formula]) and maybe a couple more things in it to calculate it precisely. So the formula is: total assigned energy/86400 (1 day in seconds) per second. Using the entire energy takes 24 hours to come back, if you have 10,000 energy, and use 5,000 energy, it will come back in 12 hours, but if you have 20,000 energy and use up 5,000 energy, it’ll be back in 6 hours.

  1. How to make a Stablecoin on tron network?
  1. How to Integrate TRC20 token in backend for Deposit and Withdraw Operations?
  1. How to Test JustSwap in TestNet?

Currently, there is no testnet for JustSwap, if you are familiar with smart contract realted development, it is very easy to integrate with justswap if you follow the developer document on justswap homepage.

  1. How can I make withdrawal from my Tron Wallet?
  1. I get «Out of Energy» error with 7656 Energy on Tronlink wallet.

That amount of energy is very low for a TRC20 contract operation. A simple transaction is about 20000 energy. You need to have some TRX to burn or stake.

  1. Are there any guides how to make TRC20 transfers via full node api?
  1. How to fetch list of transaction list by wallet address?
  1. How can i watch transactions of tron blockchain by socket?

You can do this by http api or gRPC api.

  1. The Energy consumption of Nile and Shasta TestNet?

The Nile is 3 times as the mainnet and the Shasta is the same as the mainnet.

  1. When will be possible to count estimated energy before execute transaction?
  • https://developers.tron.network/docs/greatvoyage-430bacon#1-add-a-new-field-energy_used-in-transactionextention.
  • https://developers.tron.network/docs/faq#5-how-to-calculate-the-bandwidth-and-energy-consumed-when-calling-the-contract
  1. Can I override unconfirmed transations in tron?
  1. I have successfully launched my token on mainnet. How would i get it listed on tronlink?

It will sycn to tronlink around 2 hours after you finished token record on tronscan.

  1. why need to build own fullnode?

Trongrid has Ratio limit, If you have a large business volume and frequent API visits, it will exceed the maximum visits of Trongrid. At this time, the best choice is to build your own FullNode.

  1. How can i start private network on local in my system?
  1. Do we have to use a black hole to burn tokens in Tron network? If yes, what is the official black hole address of TRC20? What is the fee and on what basis is it calculated?
  1. Startup will still be stuck after the upgrade (v4.3).

change the maxTimeRatio to above 20.0 e.g. 30.0 and restart the node.

  1. how to define the fee_limit for TRC20 token?

You can set the feelimit when you create a contract transaction, refer to the documentation https://developers.tron.network/reference#trigger-smart-contract

  1. Let’s said I’m going to trigger smart contract for transfer. Does it mean it wil out of energy if it exceed the fee limit that I set?
  1. the API URL of the tron test browser
  1. How much is the Fee to activate account on Main net?
  1. If i want to grab the latest tron/usdt price how would i go about doing so? I cannot find anywhere the API offers 😕
  1. I created a private Tron chain. It comes with TronGrid. Do I have to pay for Trongrid if my calls exceed 100K daily?

no, you dont need to pay on your own private chain.

  1. Is there a way to get information about user’s balance using only the address of wallet?

you can do this via tronweb or trongrid api

  1. Is there any IDE like Remix to develop contract?
  1. I am looking for someone to help me develop a TRC-20 stablecoin.
  1. How can i valid one address is valid?

the account is a public key created from private key, you can verify it according to this: https://developers.tron.network/docs/account

  1. I already set up fullnode and solidity node, so my question is how can i listen to new transaction received by given address ?
  1. Is there a way to pool energy or bandwith across multiple wallets? As in sharing the resources between multiple wallets.
  1. How to find out if a Tron Address is active or not?

It will return account detai via getaccount API if account is activated.

  1. What is the minimum sending amount of TRX to activate the address?

Transfer >0.1 TRX to activate the address. At least 1 TRX must be burned to activate the account. If there is not enough frozen bandwidth, an additional 0.1 TRX will be burned. In this case, it will cost 1.1 TRX to complete the creation of a new account; if there is enough frozen bandwidth, 1 TRX must be burned to complete creating the new account.

  1. Where we can find the token icon file? (manual search via google . or there is some better way? )

All token icon can be found on tronscan.

  1. is there any email list subscription to be notified about important update on full nodes? ( when we need to update our full nodes If happening any critical update)

You will see Update notification in this channel if there is a new version. or you can subscribe the release from here: https://github.com/tronprotocol/java-tron/releases

  1. Is it more profitable to freeze balance than pay fees in TRX?

Depends on your balance and daily transaction count. very much transactions, 100+. If you have more balance then freeze, your freezing resource gets filled every day. If you got 100k bandwidth, and used all of it, it will be filled to 100k the next day. You’ll get about 1.5 bandwidth for each TRX stacked

  1. Does any one know an efficient method to listen for triggered smart contract event on the tron network. Tried using tronweb’s watch method but it doesn’t pick all transactions.
  1. Sample JS code to transfer TRC20 token?
  1. I create a transaction for TRX in Tron network successfully. How can I send USDT or any other token in Tron with the Trongrid API?
  1. How to fix this «contract validate error : account does not exist»?

Probably the account is not activated, transfer >0.1 TRX to that account will activate the new accout. At least 1 TRX must be burned to activate the account. If there is not enough frozen bandwidth, an additional 0.1 TRX will be burned. In this case, it will cost 1.1 TRX to complete the creation of a new account; if there is enough frozen bandwidth, 1 TRX must be burned to complete creating the new account.

  1. How to transfer TRC10/TRC20 token and I want to see the fee when transfering?
  1. Is it possible the wallet account and account being approved both need activated?

the account must be activated if you want to start transction with that account.

  1. How to improve the sync speed or solve the sync stop problems of java-tron?
  1. a better machine such as 16 CORES + 32GB RAM, 500 GB SSD
  2. make sure single physical CPU has 16 cores or above: the following needs to be bigger or equal to 16.
  1. Change the max time toerlance to 20.0 or above:
  1. Improve the start-up by adding XX:+UseConcMarkSweepGC $java -XX:+UseConcMarkSweepGC -jar Fullnode.jar -c config.conf
  1. Is it harmful or advantageous to use a public node instead of setting up my own node?

depends on your own requirement, public nodes are mainly for seed nodes, it cannot support very limited requests, too many requests may cause the node stop working. If you have a large number of requests, it is best to use your own Node, because your own Node only serves you and is more secure.

  1. first you have to write the smart contract for your coin.
  2. deploy your token’s smart contract.
  3. from this link you can record your trx20 token: https://tronscan.org/#/tokens/create/Type
  1. I got this number from api. amount_str = «2535672» how can i understand how much is this? how can i convert it to exact amount? 🤔
  1. What are internal transactions?
  1. Can I generate TRC20 address in Mainnet? I need generate TRC20 adrress while become a member for all user.
  1. Is there a method to get the current chain id on TronWeb instance?
  1. Can anyone help me learn to add liquidity to my TRC 20 token?
  1. We are developing an exchange software that use TronGrid to manage transactions, Is this the best way? Or run the Full node?

depends on the request volume, if the trongrid free volume cannot meet your requirement , you need to set up your own node.

  1. How to get «REST API endpoint providing circulating supply value» for certain token using http? Token: https://tronscan.org/#/token20/TThrzAzRj2Pw4CQjqo1dk2zGyifPhuNHRu/ I need to get something like this: http://explorer.litecoin.net/chain/Litecoin/q/totalbc (only pure number «9,964,245,481.605456077196663259» using http)
  1. How much energy can I get by staking 1000 TRX?

With 1000 TRX, you can get estimated gain 1000 TRON Power and 25970.664 Energy. You can see this at tronscan.io when you staking the TRX.

  1. Is there an API to get the unit price of energy?
  1. Where can i find documentation for setting up event server in vps? Right now, i am trying to «deploy tron event subscription plugin» but i am not sure if i am doing something wrong or documentation is broken. I need this to fetch user’s NFT balance and some other events.
  1. I cannot get any information of a tron wallet on tronscan.org or using trongrid API

only activated account can return data. non-activated account will return empty. Transfer > 0.1 TRX to that account will activate that account.

  1. Getting 503 Errors: Failed to load resource: the server responded with a status of 503 (). This happen 100% of the times on the main net, on Nile everything works as expected.

IP or API-KEY access exceeds frequency limit, max 15 times/s

  1. Is possible to send energy to address in tron network?

You cannot send energy to other address, however you can set the receive address when you freezing TRX for energy.

  1. How can I get a api of Energy By Burning TRX?
  1. How can we forecast how much SUN = 1 Energy?

https://api.trongrid.io/wallet/getaccountresource?address=TEi9FxmwRAGncvMLEdgKpFsQrGBgAZywC7&visible=true you can see the total energy and total freezing TRX for energy , Based on this, you can roughly estimate how much energy the new freezing TRX can obtain:

1 TRX = 1000000 sun, e.g. 280 sun means 0.00028 TRX.

  1. I got this error <«result»:<«code»:»OTHER_ERROR»,»message»:»636c617373206f72672e74726f6e2e636f72652e73657276696365732e687474702e4a736f6e466f726d6174245061727365457863657074696f6e203a20343a32363a20494e56414c49442068657820537472696e67″>> — How can I decode the message?

  1. How to generate address offline?

Some Demo code of Generate address offline(means generate address locally):

  • java: https://github.com/tronprotocol/java-tron/blob/develop/framework/src/main/java/org/tron/core/services/http/GenerateAddressServlet.java#L23
  • Python: https://github.com/andelf/tronpy/blob/8beacd905ecd8cb151498748e2d446004c0b53ff/tronpy/tron.py#L458
  • Java-script: https://github.com/tronprotocol/tronweb/blob/34cb9c5ac0f5167b0660e663583d973949868e04/src/index.js#L393
  • C sharp: https://github.com/farukterzioglu/TronSharp/blob/master/TronSharp.Tests/Singature/SignWithPrivateKey.cs
  • Java: https://cn.developers.tron.network/docs/%E6%9C%AC%E5%9C%B0%E6%9E%84%E5%BB%BA%E4%BA%A4%E6%98%93
  • Python: https://github.com/andelf/tronpy/blob/8beacd905ecd8cb151498748e2d446004c0b53ff/tronpy/tron.py#L130
  • Java-script: https://github.com/tronprotocol/tronweb/blob/34cb9c5ac0f5167b0660e663583d973949868e04/src/lib/trx.js#L650
  1. How do I calculate contract call bandwidth and energy values? Are there any relevant code samples?
  1. How can I check balance of USDT trc20 token?
  1. How can ı create seed phrase from keystore?
  1. What is an offline mode? And can I create a account with PHP?

offline mode ≈ create it via SDK. We can create address with library instead of communicating with the node.

  1. Does any one know about ByteString convert to readable string in trident-java get transaction by id, and the return value such like below:
  1. Validate signature error: xxxx is signed by xxxx but it is not contained of permission

You are using wrong private key. The private key must the priavate key of the owner_address.

  1. Does tronweb have the function of identifying and observing the wallet?

This feature is not currently available on tronweb.

  1. How to get address using trident-java?
  1. How to Transfer TRC-20 using Python?
  1. when running a litenode that was started from a database snapshot, is there a way to compress the current database when it gets to big for the litenode to store?
  1. If i want to listen trc20 transaction for certain address, should i develop a full node?

https://developers.tron.network/v3.7/docs/tronweb-trx-functions
Get all transaction detail by block with tronWeb.trx.getBlock(12345); thus no need for a full node.

  1. How should I monitor real-time transfer events on the chain?
  • one is using event plugin: https://developers.tron.network/docs/event-subscribe
  • one is scanning the block: please refer to the doc: https://developers.tron.network/docs/how-to-determine-address-recharge
  1. owner_address Why is this parameter mandatory? We can activate the newly created account later.

activate account has cost, you have the specify the owner account to pay the cost.

  1. How to get user’s authority so that can check his balance with wallet address?

you don’t need user authority to check balance. Just call the BalanceOf(address) funtion of the token contract, or use the Tronlink api for TRX balance

  1. How to check confirmation of the transaction?
  1. How much fee for issuing a TRC10 token?
  1. Is there a way to predict block hash values?
  1. I have a tron address but lost the private key, is there anyway to regain (recover) this?
  1. Does TRON have any documentation that encapsulates the API? Interfaces can be called directly, like API
  1. How to listen to wallet address deposit? You can use:
  • event plugin: https://developers.tron.network/docs/event-subscribe
  • scanning blocks: https://developers.tron.network/docs/faq#14how-to-judge-the-recharge-and-withdraw-funds-by-scanning-the-block
  1. How to transfer TRX to another account using Javascript (tronweb)?
  1. Can i pay fees in tron and not freeze my tron?
  1. I want to create a raw transaction (without signing it) and get its hash in hex format. The official TRON API normally returns a JSON for creating transactions. Does anybody here know how to do this?
  1. How to Convert TRX to SUN using tronWeb?
  1. is it possible to hide transaction for any particular wallet?

No way, block chain is a fully transparent platform. all transactions are public.

  1. can we block any particular wallet, if someone steal crypto & is it possible to block those users so they can not able to access to those funds?

No. Blockchain is decentralised. As long as you have private keys, you have accessed to the funds in your wallet. However, there are several work arounds from centralized org.

  • USDT contract do support account block if user report it is a scam.
  • Exchanges usually also support account block if the money goes to the exchange.
  • CEX can block because they internally use Wallet Mechanism
  1. curl -X GET http://127.0.0.1:8090/wallet/getnowblock curl: (7) Failed connect to 127.0.0.1:8090; Connection refused
  • check whether your node is still running.
  • Check your server configuration and see whether 8090 is enabled.
  1. I by mistake deposited USDT on my tronlink wallet usdt contract address. Is there a way to retreive/recover the coins?
  1. How do I get the current USDT price?
  1. Does tronscan have api to get chain id or net id like ethereum?

TRON has no concept of chainid.

  1. How long does it take for a successfully broadcasted transaction that did not appear on the blockchain to expire?

https://developers.tron.network/docs/tron-protocol-transaction#transaction-confirmation The mechanism of TRON’s block validation is that a block is validated after this block is produced and 19 different SRs produce subsequent blocks based on this block.

  1. Can the wallet address be customized?
  1. Is it possible to get a list all holder addresses from a defined trc20 token via API?
  1. How can I add tron network on coinbase wallet?
  1. Which API of Trongrid queries the balance of USDT?
  1. Does Tron have a json rpc api like Ethereum?
  1. How much bandwidth/energy for freezing the TRX?
  1. How to freeze trx for account that i created using tronweb?
  1. Is there a way to upload a custom abi on Tronscan for a contract already deployed?
  1. How to transfer or send USDT from one wallet to another wallet using TronWeb?
  1. How to transfer or send TRX from one wallet to another wallet using TronWeb?
  1. What are the USDT Contract Addresses (TRC-20)?
  • Main Net: TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
  • Shasta TestNet: TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs
  • Nile TestNet: TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf
  1. How can I validate a Tron Wallet Address using Tronweb?

You can use TronWeb.isAddress method to validate an address.

  1. What is the difference between Energy and Bandwidth in Tron?
  1. Is there a beginner’s guide to deploy a smart contract on tron?
  1. How to Verify a Signature of a Signed Hex Message?
  1. How to Convert Base58 to Hex Tron TRC20?
  1. What is the «visible» parameter? POST /wallet/createtransaction

It is the address format, visible true for base58 and false for hex format.

Источник

`pragma solidity ^0.4.25;

// * Uses hybrid commit-reveal + block hash random number generation that is immune
// to tampering by players, house and miners. Apart from being fully transparent,
// this also allows arbitrarily high bets.
//
// * Refer to https://dice2.win/whitepaper.pdf for detailed description and proofs.

contract Dice2Win {
/// *** Constants section

// Each bet is deducted 1% in favour of the house, but no less than some minimum.
// The lower bound is dictated by gas costs of the settleBet transaction, providing
// headroom for up to 10 Gsun prices.
uint constant HOUSE_EDGE_PERCENT = 1;
uint constant HOUSE_EDGE_MINIMUM_AMOUNT = 0.0003 trx;

// Bets lower than this amount do not participate in jackpot rolls (and are
// not deducted JACKPOT_FEE).
uint constant MIN_JACKPOT_BET = 0.1 trx;

// Chance to win jackpot (currently 0.1%) and fee deducted into jackpot fund.
uint constant JACKPOT_MODULO = 1000;
uint constant JACKPOT_FEE = 0.001 trx;

// There is minimum and maximum bets.
uint constant MIN_BET = 0.01 trx;
uint constant MAX_AMOUNT = 300000 trx;

// Modulo is a number of equiprobable outcomes in a game:
//  - 2 for coin flip
//  - 6 for dice
//  - 6*6 = 36 for double dice
//  - 100 for trxoll
//  - 37 for roulette
//  etc.
// It's called so because 256-bit entropy is treated like a huge integer and
// the remainder of its division by modulo is considered bet outcome.
uint constant MAX_MODULO = 100;

// For modulos below this threshold rolls are checked against a bit mask,
// thus allowing betting on any combination of outcomes. For example, given
// modulo 6 for dice, 101000 mask (base-2, big endian) means betting on
// 4 and 6; for games with modulos higher than threshold (Etheroll), a simple
// limit is used, allowing betting on any outcome in [0, N) range.
//
// The specific value is dictated by the fact that 256-bit intermediate
// multiplication result allows implementing population count efficiently
// for numbers that are up to 42 bits, and 40 is the highest multiple of
// eight below 42.
uint constant MAX_MASK_MODULO = 40;

// This is a check on bet mask overflow.
uint constant MAX_BET_MASK = 2 ** MAX_MASK_MODULO;

// EVM BLOCKHASH opcode can query no further than 256 blocks into the
// past. Given that settleBet uses block hash of placeBet as one of
// complementary entropy sources, we cannot process bets older than this
// threshold. On rare occasions dice2.win croupier may fail to invoke
// settleBet in this timespan due to technical issues or extreme Ethereum
// congestion; such bets can be refunded via invoking refundBet.
uint constant BET_EXPIRATION_BLOCKS = 250;

// Some deliberately invalid address to initialize the secret signer with.
// Forces maintainers to invoke setSecretSigner before processing any bets.
address constant DUMMY_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

// Standard contract ownership transfer.
address public owner;
address private nextOwner;

// Adjustable max bet profit. Used to cap bets against dynamic odds.
uint public maxProfit;

// The address corresponding to a private key used to sign placeBet commits.
address public secretSigner;

// Accumulated jackpot fund.
uint128 public jackpotSize;

// Funds that are locked in potentially winning bets. Prevents contract from
// committing to bets it cannot pay out.
uint128 public lockedInBets;

// A structure representing a single bet.
struct Bet {
    // Wager amount in sun.
    uint amount;
    // Modulo of a game.
    uint8 modulo;
    // Number of winning outcomes, used to compute winning payment (* modulo/rollUnder),
    // and used instead of mask for games with modulo > MAX_MASK_MODULO.
    uint8 rollUnder;
    // Block number of placeBet tx.
    uint40 placeBlockNumber;
    // Bit mask representing winning bet outcomes (see MAX_MASK_MODULO comment).
    uint40 mask;
    // Address of a gambler, used to pay out winning bets.
    address gambler;
}

// Mapping from commits to all currently active & processed bets.
mapping (uint => Bet) bets;

// Croupier account.
address public croupier;

// Events that are issued to make statistic recovery easier.
event FailedPayment(address indexed beneficiary, uint amount);
event Payment(address indexed beneficiary, uint amount);
event JackpotPayment(address indexed beneficiary, uint amount);

// This event is emitted in placeBet to record commit in the logs.
event Commit(uint commit);

// Constructor. Deliberately does not take any parameters.
constructor () public {
    owner = msg.sender;
    secretSigner = DUMMY_ADDRESS;
    croupier = DUMMY_ADDRESS;
}

// Standard modifier on methods invokable only by contract owner.
modifier onlyOwner {
    require (msg.sender == owner, "OnlyOwner methods called by non-owner.");
    _;
}

// Standard modifier on methods invokable only by contract owner.
modifier onlyCroupier {
    require (msg.sender == croupier, "OnlyCroupier methods called by non-croupier.");
    _;
}

// Standard contract ownership transfer implementation,
function approveNextOwner(address _nextOwner) external onlyOwner {
    require (_nextOwner != owner, "Cannot approve current owner.");
    nextOwner = _nextOwner;
}

function acceptNextOwner() external {
    require (msg.sender == nextOwner, "Can only accept preapproved new owner.");
    owner = nextOwner;
}

// Fallback function deliberately left empty. It's primary use case
// is to top up the bank roll.
function () public payable {
}

// See comment for "secretSigner" variable.
function setSecretSigner(address newSecretSigner) external onlyOwner {
    secretSigner = newSecretSigner;
}

// Change the croupier address.
function setCroupier(address newCroupier) external onlyOwner {
    croupier = newCroupier;
}

// Change max bet reward. Setting this to zero effectively disables betting.
function setMaxProfit(uint _maxProfit) public onlyOwner {
    require (_maxProfit < MAX_AMOUNT, "maxProfit should be a sane number.");
    maxProfit = _maxProfit;
}

// This function is used to bump up the jackpot fund. Cannot be used to lower it.
function increaseJackpot(uint increaseAmount) external onlyOwner {
    require (increaseAmount <= address(this).balance, "Increase amount larger than balance.");
    require (jackpotSize + lockedInBets + increaseAmount <= address(this).balance, "Not enough funds.");
    jackpotSize += uint128(increaseAmount);
}

// Funds withdrawal to cover costs of dice2.win operation.
function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner {
    require (withdrawAmount <= address(this).balance, "Increase amount larger than balance.");
    require (jackpotSize + lockedInBets + withdrawAmount <= address(this).balance, "Not enough funds.");
    sendFunds(beneficiary, withdrawAmount, withdrawAmount);
}

// Contract may be destroyed only when there are no ongoing bets,
// either settled or refunded. All funds are transferred to contract owner.
function kill() external onlyOwner {
    require (lockedInBets == 0, "All bets should be processed (settled or refunded) before self-destruct.");
    selfdestruct(owner);
}

/// *** Betting logic

// Bet states:
//  amount == 0 && gambler == 0 - 'clean' (can place a bet)
//  amount != 0 && gambler != 0 - 'active' (can be settled or refunded)
//  amount == 0 && gambler != 0 - 'processed' (can clean storage)
//
//  NOTE: Storage cleaning is not implemented in this contract version; it will be added
//        with the next upgrade to prevent polluting Ethereum state with expired bets.

// Bet placing transaction - issued by the player.
//  betMask         - bet outcomes bit mask for modulo <= MAX_MASK_MODULO,
//                    [0, betMask) for larger modulos.
//  modulo          - game modulo.
//  commitLastBlock - number of the maximum block where "commit" is still considered valid.
//  commit          - Keccak256 hash of some secret "reveal" random number, to be supplied
//                    by the dice2.win croupier bot in the settleBet transaction. Supplying
//                    "commit" ensures that "reveal" cannot be changed behind the scenes
//                    after placeBet have been mined.
//  r, s            - components of ECDSA signature of (commitLastBlock, commit). v is
//                    guaranteed to always equal 27.
//
// Commit, being essentially random 256-bit number, is used as a unique bet identifier in
// the 'bets' mapping.
//
// Commits are signed with a block limit to ensure that they are used at most once - otherwise
// it would be possible for a miner to place a bet with a known commit/reveal pair and tamper
// with the blockhash. Croupier guarantees that commitLastBlock will always be not greater than
// placeBet block number plus BET_EXPIRATION_BLOCKS. See whitepaper for details.
function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s) external payable {
    // Check that the bet is in 'clean' state.
    Bet storage bet = bets[commit];
    require (bet.gambler == address(0), "Bet should be in a 'clean' state.");

    // Validate input data ranges.
    uint amount = msg.value;
    require (modulo > 1 && modulo <= MAX_MODULO, "Modulo should be within range.");
    require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");
    require (betMask > 0 && betMask < MAX_BET_MASK, "Mask should be within range.");

    // Check that commit is valid - it has not expired and its signature is valid.
    require (block.number <= commitLastBlock, "Commit has expired.");
    bytes32 signatureHash = keccak256(abi.encodePacked(uint40(commitLastBlock), commit));
    require (secretSigner == ecrecover(signatureHash, 27, r, s), "ECDSA signature is not valid.");

    uint rollUnder;
    uint mask;

    if (modulo <= MAX_MASK_MODULO) {
        // Small modulo games specify bet outcomes via bit mask.
        // rollUnder is a number of 1 bits in this mask (population count).
        // This magic looking formula is an efficient way to compute population
        // count on EVM for numbers below 2**40. For detailed proof consult
        // the dice2.win whitepaper.
        rollUnder = ((betMask * POPCNT_MULT) & POPCNT_MASK) % POPCNT_MODULO;
        mask = betMask;
    } else {
        // Larger modulos specify the right edge of half-open interval of
        // winning bet outcomes.
        require (betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo.");
        rollUnder = betMask;
    }

    // Winning amount and jackpot increase.
    uint possibleWinAmount;
    uint jackpotFee;

    (possibleWinAmount, jackpotFee) = getDiceWinAmount(amount, modulo, rollUnder);

    // Enforce max profit limit.
    require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");

    // Lock funds.
    lockedInBets += uint128(possibleWinAmount);
    jackpotSize += uint128(jackpotFee);

    // Check whether contract has enough funds to process this bet.
    require (jackpotSize + lockedInBets <= address(this).balance, "Cannot afford to lose this bet.");

    // Record commit in logs.
    emit Commit(commit);

    // Store bet parameters on blockchain.
    bet.amount = amount;
    bet.modulo = uint8(modulo);
    bet.rollUnder = uint8(rollUnder);
    bet.placeBlockNumber = uint40(block.number);
    bet.mask = uint40(mask);
    bet.gambler = msg.sender;
}

// This is the method used to settle 99% of bets. To process a bet with a specific
// "commit", settleBet should supply a "reveal" number that would Keccak256-hash to
// "commit". "blockHash" is the block hash of placeBet block as seen by croupier; it
// is additionally asserted to prevent changing the bet outcomes on Ethereum reorgs.
function settleBet(uint reveal, bytes32 blockHash) external onlyCroupier {
    uint commit = uint(keccak256(abi.encodePacked(reveal)));

    Bet storage bet = bets[commit];
    uint placeBlockNumber = bet.placeBlockNumber;

    // Check that bet has not expired yet (see comment to BET_EXPIRATION_BLOCKS).
    require (block.number > placeBlockNumber, "settleBet in the same block as placeBet, or before.");
    require (block.number <= placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
    require (blockhash(placeBlockNumber) == blockHash);

    // Settle bet using reveal and blockHash as entropy sources.
    settleBetCommon(bet, reveal, blockHash);
}

// This method is used to settle a bet that was mined into an uncle block. At this
// point the player was shown some bet outcome, but the blockhash at placeBet height
// is different because of Ethereum chain reorg. We supply a full merkle proof of the
// placeBet transaction receipt to provide untamperable evidence that uncle block hash
// indeed was present on-chain at some point.
function settleBetUncleMerkleProof(uint reveal, uint40 canonicalBlockNumber) external onlyCroupier {
    // "commit" for bet settlement can only be obtained by hashing a "reveal".
    uint commit = uint(keccak256(abi.encodePacked(reveal)));

    Bet storage bet = bets[commit];

    // Check that canonical block hash can still be verified.
    require (block.number <= canonicalBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

    // Verify placeBet receipt.
    requireCorrectReceipt(4 + 32 + 32 + 4);

    // Reconstruct canonical & uncle block hashes from a receipt merkle proof, verify them.
    bytes32 canonicalHash;
    bytes32 uncleHash;
    (canonicalHash, uncleHash) = verifyMerkleProof(commit, 4 + 32 + 32);
    require (blockhash(canonicalBlockNumber) == canonicalHash);

    // Settle bet using reveal and uncleHash as entropy sources.
    settleBetCommon(bet, reveal, uncleHash);
}

// Common settlement code for settleBet & settleBetUncleMerkleProof.
function settleBetCommon(Bet storage bet, uint reveal, bytes32 entropyBlockHash) private {
    // Fetch bet parameters into local variables (to save gas).
    uint amount = bet.amount;
    uint modulo = bet.modulo;
    uint rollUnder = bet.rollUnder;
    address gambler = bet.gambler;

    // Check that bet is in 'active' state.
    require (amount != 0, "Bet should be in an 'active' state");

    // Move bet into 'processed' state already.
    bet.amount = 0;

    // The RNG - combine "reveal" and blockhash of placeBet using Keccak256. Miners
    // are not aware of "reveal" and cannot deduce it from "commit" (as Keccak256
    // preimage is intractable), and house is unable to alter the "reveal" after
    // placeBet have been mined (as Keccak256 collision finding is also intractable).
    bytes32 entropy = keccak256(abi.encodePacked(reveal, entropyBlockHash));

    // Do a roll by taking a modulo of entropy. Compute winning amount.
    uint dice = uint(entropy) % modulo;

    uint diceWinAmount;
    uint _jackpotFee;
    (diceWinAmount, _jackpotFee) = getDiceWinAmount(amount, modulo, rollUnder);

    uint diceWin = 0;
    uint jackpotWin = 0;

    // Determine dice outcome.
    if (modulo <= MAX_MASK_MODULO) {
        // For small modulo games, check the outcome against a bit mask.
        if ((2 ** dice) & bet.mask != 0) {
            diceWin = diceWinAmount;
        }

    } else {
        // For larger modulos, check inclusion into half-open interval.
        if (dice < rollUnder) {
            diceWin = diceWinAmount;
        }

    }

    // Unlock the bet amount, regardless of the outcome.
    lockedInBets -= uint128(diceWinAmount);

    // Roll for a jackpot (if eligible).
    if (amount >= MIN_JACKPOT_BET) {
        // The second modulo, statistically independent from the "main" dice roll.
        // Effectively you are playing two games at once!
        uint jackpotRng = (uint(entropy) / modulo) % JACKPOT_MODULO;

        // Bingo!
        if (jackpotRng == 0) {
            jackpotWin = jackpotSize;
            jackpotSize = 0;
        }
    }

    // Log jackpot win.
    if (jackpotWin > 0) {
        emit JackpotPayment(gambler, jackpotWin);
    }

    // Send the funds to gambler.
    sendFunds(gambler, diceWin + jackpotWin == 0 ? 1 sun : diceWin + jackpotWin, diceWin);
}

// Refund transaction - return the bet amount of a roll that was not processed in a
// due timeframe. Processing such blocks is not possible due to EVM limitations (see
// BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself
// in a situation like this, just contact the dice2.win support, however nothing
// precludes you from invoking this method yourself.
function refundBet(uint commit) external {
    // Check that bet is in 'active' state.
    Bet storage bet = bets[commit];
    uint amount = bet.amount;

    require (amount != 0, "Bet should be in an 'active' state");

    // Check that bet has already expired.
    require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");

    // Move bet into 'processed' state, release funds.
    bet.amount = 0;

    uint diceWinAmount;
    uint jackpotFee;
    (diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.modulo, bet.rollUnder);

    lockedInBets -= uint128(diceWinAmount);
    jackpotSize -= uint128(jackpotFee);

    // Send the refund.
    sendFunds(bet.gambler, amount, amount);
}

// Get the expected win amount after house edge is subtracted.
function getDiceWinAmount(uint amount, uint modulo, uint rollUnder) private pure returns (uint winAmount, uint jackpotFee) {
    require (0 < rollUnder && rollUnder <= modulo, "Win probability out of range.");

    jackpotFee = amount >= MIN_JACKPOT_BET ? JACKPOT_FEE : 0;

    uint houseEdge = amount * HOUSE_EDGE_PERCENT / 100;

    if (houseEdge < HOUSE_EDGE_MINIMUM_AMOUNT) {
        houseEdge = HOUSE_EDGE_MINIMUM_AMOUNT;
    }

    require (houseEdge + jackpotFee <= amount, "Bet doesn't even cover house edge.");
    winAmount = (amount - houseEdge - jackpotFee) * modulo / rollUnder;
}

// Helper routine to process the payment.
function sendFunds(address beneficiary, uint amount, uint successLogAmount) private {
    if (beneficiary.send(amount)) {
        emit Payment(beneficiary, successLogAmount);
    } else {
        emit FailedPayment(beneficiary, amount);
    }
}

// This are some constants making O(1) population count in placeBet possible.
// See whitepaper for intuition and proofs behind it.
uint constant POPCNT_MULT = 0x0000000000002000000000100000000008000000000400000000020000000001;
uint constant POPCNT_MASK = 0x0001041041041041041041041041041041041041041041041041041041041041;
uint constant POPCNT_MODULO = 0x3F;

// *** Merkle proofs.

// This helpers are used to verify cryptographic proofs of placeBet inclusion into
// uncle blocks. They are used to prevent bet outcome changing on Ethereum reorgs without
// compromising the security of the smart contract. Proof data is appended to the input data
// in a simple prefix length format and does not adhere to the ABI.
// Invariants checked:
//  - receipt trie entry contains a (1) successful transaction (2) directed at this smart
//    contract (3) containing commit as a payload.
//  - receipt trie entry is a part of a valid merkle proof of a block header
//  - the block header is a part of uncle list of some block on canonical chain
// The implementation is optimized for gas cost and relies on the specifics of Ethereum internal data structures.
// Read the whitepaper for details.

// Helper to verify a full merkle proof starting from some seedHash (usually commit). "offset" is the location of the proof
// beginning in the calldata.
function verifyMerkleProof(uint seedHash, uint offset) pure private returns (bytes32 blockHash, bytes32 uncleHash) {
    // (Safe) assumption - nobody will write into RAM during this method invocation.
    uint scratchBuf1;  assembly { scratchBuf1 := mload(0x40) }

    uint uncleHeaderLength; uint blobLength; uint shift; uint hashSlot;

    // Verify merkle proofs up to uncle block header. Calldata layout is:
    //  - 2 byte big-endian slice length
    //  - 2 byte big-endian offset to the beginning of previous slice hash within the current slice (should be zeroed)
    //  - followed by the current slice verbatim
    for (;; offset += blobLength) {
        assembly { blobLength := and(calldataload(sub(offset, 30)), 0xffff) }
        if (blobLength == 0) {
            // Zero slice length marks the end of uncle proof.
            break;
        }

        assembly { shift := and(calldataload(sub(offset, 28)), 0xffff) }
        require (shift + 32 <= blobLength, "Shift bounds check.");

        offset += 4;
        assembly { hashSlot := calldataload(add(offset, shift)) }
        require (hashSlot == 0, "Non-empty hash slot.");

        assembly {
            calldatacopy(scratchBuf1, offset, blobLength)
            mstore(add(scratchBuf1, shift), seedHash)
            seedHash := keccak256(scratchBuf1, blobLength)
            uncleHeaderLength := blobLength
        }
    }

    // At this moment the uncle hash is known.
    uncleHash = bytes32(seedHash);

    // Construct the uncle list of a canonical block.
    uint scratchBuf2 = scratchBuf1 + uncleHeaderLength;
    uint unclesLength; assembly { unclesLength := and(calldataload(sub(offset, 28)), 0xffff) }
    uint unclesShift;  assembly { unclesShift := and(calldataload(sub(offset, 26)), 0xffff) }
    require (unclesShift + uncleHeaderLength <= unclesLength, "Shift bounds check.");

    offset += 6;
    assembly { calldatacopy(scratchBuf2, offset, unclesLength) }
    memcpy(scratchBuf2 + unclesShift, scratchBuf1, uncleHeaderLength);

    assembly { seedHash := keccak256(scratchBuf2, unclesLength) }

    offset += unclesLength;

    // Verify the canonical block header using the computed keccak256Uncles.
    assembly {
        blobLength := and(calldataload(sub(offset, 30)), 0xffff)
        shift := and(calldataload(sub(offset, 28)), 0xffff)
    }
    require (shift + 32 <= blobLength, "Shift bounds check.");

    offset += 4;
    assembly { hashSlot := calldataload(add(offset, shift)) }
    require (hashSlot == 0, "Non-empty hash slot.");

    assembly {
        calldatacopy(scratchBuf1, offset, blobLength)
        mstore(add(scratchBuf1, shift), seedHash)

        // At this moment the canonical block hash is known.
        blockHash := keccak256(scratchBuf1, blobLength)
    }
}

// Helper to check the placeBet receipt. "offset" is the location of the proof beginning in the calldata.
// RLP layout: [triePath, str([status, cumGasUsed, bloomFilter, [[address, [topics], data]])]
function requireCorrectReceipt(uint offset) view private {
    uint leafHeaderByte; assembly { leafHeaderByte := byte(0, calldataload(offset)) }

    require (leafHeaderByte >= 0xf7, "Receipt leaf longer than 55 bytes.");
    offset += leafHeaderByte - 0xf6;

    uint pathHeaderByte; assembly { pathHeaderByte := byte(0, calldataload(offset)) }

    if (pathHeaderByte <= 0x7f) {
        offset += 1;

    } else {
        require (pathHeaderByte >= 0x80 && pathHeaderByte <= 0xb7, "Path is an RLP string.");
        offset += pathHeaderByte - 0x7f;
    }

    uint receiptStringHeaderByte; assembly { receiptStringHeaderByte := byte(0, calldataload(offset)) }
    require (receiptStringHeaderByte == 0xb9, "Receipt string is always at least 256 bytes long, but less than 64k.");
    offset += 3;

    uint receiptHeaderByte; assembly { receiptHeaderByte := byte(0, calldataload(offset)) }
    require (receiptHeaderByte == 0xf9, "Receipt is always at least 256 bytes long, but less than 64k.");
    offset += 3;

    uint statusByte; assembly { statusByte := byte(0, calldataload(offset)) }
    require (statusByte == 0x1, "Status should be success.");
    offset += 1;

    uint cumGasHeaderByte; assembly { cumGasHeaderByte := byte(0, calldataload(offset)) }
    if (cumGasHeaderByte <= 0x7f) {
        offset += 1;

    } else {
        require (cumGasHeaderByte >= 0x80 && cumGasHeaderByte <= 0xb7, "Cumulative gas is an RLP string.");
        offset += cumGasHeaderByte - 0x7f;
    }

    uint bloomHeaderByte; assembly { bloomHeaderByte := byte(0, calldataload(offset)) }
    require (bloomHeaderByte == 0xb9, "Bloom filter is always 256 bytes long.");
    offset += 256 + 3;

    uint logsListHeaderByte; assembly { logsListHeaderByte := byte(0, calldataload(offset)) }
    require (logsListHeaderByte == 0xf8, "Logs list is less than 256 bytes long.");
    offset += 2;

    uint logEntryHeaderByte; assembly { logEntryHeaderByte := byte(0, calldataload(offset)) }
    require (logEntryHeaderByte == 0xf8, "Log entry is less than 256 bytes long.");
    offset += 2;

    uint addressHeaderByte; assembly { addressHeaderByte := byte(0, calldataload(offset)) }
    require (addressHeaderByte == 0x94, "Address is 20 bytes long.");

    uint logAddress; assembly { logAddress := and(calldataload(sub(offset, 11)), 0xffffffffffffffffffffffffffffffffffffffff) }
    require (logAddress == uint(address(this)));
}

// Memory copy.
function memcpy(uint dest, uint src, uint len) pure private {
    // Full 32 byte words
    for(; len >= 32; len -= 32) {
        assembly { mstore(dest, mload(src)) }
        dest += 32; src += 32;
    }

    // Remaining bytes
    uint mask = 256 ** (32 - len) - 1;
    assembly {
        let srcpart := and(mload(src), not(mask))
        let destpart := and(mload(dest), mask)
        mstore(dest, or(destpart, srcpart))
    }
}

}`

This is my tron contract contact.Tron studio compiles it successfully.
tronbox compile —all alos compiles successfully without a warning.

tronbox migrate —network development —reset
Using network ‘development’.

Running migration: 1_initial_migration.js
Deploying Dice2Win…
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Unknown error: {
«code»: «CONTRACT_VALIDATE_ERROR»,
«message»: «636f6e74726163742076616c6964617465206572726f72203a20546865206f726967696e456e657267794c696d6974206d757374206265203e2030»
}
at /Users/yhw/.nvm/versions/node/v8.11.3/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:135:1
at
at process._tickCallback (internal/process/next_tick.js:188:7)

Any suggestions?

Понравилась статья? Поделить с друзьями:
  • Trigger error sql
  • Trigger error message mysql
  • Tried to read nbt tag that was too big tried to allocate ошибка minecraft
  • Tribes of midgard fatal error
  • Tribal error скачать торрент