tronprotocol / java-tron

Java implementation of the Tron whitepaper
GNU Lesser General Public License v3.0
3.75k stars 1.41k forks source link

How much TRX will cost to deoloy a smart contract on Tron? #5941

Closed abn2357 closed 3 months ago

0xbigapple commented 4 months ago

Deploying a smart contract on Tron consumes bandwidth and energy,the amount is related to the contract's complexity.

bandwidth calculations here. The unit price of bandwidth is 0.001TRX.

energy calculations here .The unit price of Energy is 0.00042TRX.

abn2357 commented 4 months ago

Deploying a smart contract on Tron consumes bandwidth and energy,the amount is related to the contract's complexity.

bandwidth calculations here. The unit price of bandwidth is 0.001TRX.

energy calculations here .The unit price of Energy is 0.00042TRX.

@0xbigapple Which kind of complexity?Could you give me more detail information?For example, I know size of contract affect bandwidth consumption

endiaoekoe commented 4 months ago

@abn2357 per my understanding ,there are several factors which have effect on the cost amount for deploy a smart contract,as below: 1.Code Length: Longer code requires more storage space, potentially increasing deployment costs. 2.Number and Complexity of Functions: The logical complexity of each function also contributes to overall complexity. 3.Data Structures: Complex data structures (e.g., nested mappings, large arrays) increase complexity. 4.Loops and Recursion: Contracts with loops (especially nested ones) and recursive functions are typically more complex. These structures can lead to higher computational complexity and gas consumption. 5.External Contract Interactions: Frequency and method of interactions with other contracts. Frequent calls to external contracts or libraries increase complexity.

abn2357 commented 4 months ago

@abn2357 per my understanding ,there are several factors which have effect on the cost amount for deploy a smart contract,as below: 1.Code Length: Longer code requires more storage space, potentially increasing deployment costs. 2.Number and Complexity of Functions: The logical complexity of each function also contributes to overall complexity. 3.Data Structures: Complex data structures (e.g., nested mappings, large arrays) increase complexity. 4.Loops and Recursion: Contracts with loops (especially nested ones) and recursive functions are typically more complex. These structures can lead to higher computational complexity and gas consumption. 5.External Contract Interactions: Frequency and method of interactions with other contracts. Frequent calls to external contracts or libraries increase complexity.

@endiaoekoe I have a question about "Complexity of Functions", I just deploy a smart contract, not to call a function of the smart contract, Why the deploying fee involved in with Complexity of Functions?

endiaoekoe commented 4 months ago

@abn2357 per my understanding ,there are several factors which have effect on the cost amount for deploy a smart contract,as below: 1.Code Length: Longer code requires more storage space, potentially increasing deployment costs. 2.Number and Complexity of Functions: The logical complexity of each function also contributes to overall complexity. 3.Data Structures: Complex data structures (e.g., nested mappings, large arrays) increase complexity. 4.Loops and Recursion: Contracts with loops (especially nested ones) and recursive functions are typically more complex. These structures can lead to higher computational complexity and gas consumption. 5.External Contract Interactions: Frequency and method of interactions with other contracts. Frequent calls to external contracts or libraries increase complexity.

@endiaoekoe I have a question about "Complexity of Functions", I just deploy a smart contract, not to call a function of the smart contract, Why the deploying fee involved in with Complexity of Functions?

@abn2357 when deploy a smart contract, for example, if the function is highly optimized ,it will save a lot of fee.otherwise,it will cost more fees when deploy it.

abn2357 commented 4 months ago

@abn2357 per my understanding ,there are several factors which have effect on the cost amount for deploy a smart contract,as below: 1.Code Length: Longer code requires more storage space, potentially increasing deployment costs. 2.Number and Complexity of Functions: The logical complexity of each function also contributes to overall complexity. 3.Data Structures: Complex data structures (e.g., nested mappings, large arrays) increase complexity. 4.Loops and Recursion: Contracts with loops (especially nested ones) and recursive functions are typically more complex. These structures can lead to higher computational complexity and gas consumption. 5.External Contract Interactions: Frequency and method of interactions with other contracts. Frequent calls to external contracts or libraries increase complexity.

@endiaoekoe I have a question about "Complexity of Functions", I just deploy a smart contract, not to call a function of the smart contract, Why the deploying fee involved in with Complexity of Functions?

@abn2357 when deploy a smart contract, for example, if the function is highly optimized ,it will save a lot of fee.otherwise,it will cost more fees when deploy it.

@endiaoekoe I think it is not the answer of my question. Does "Complexity of Functions" means those functions that will be called like the constructor function when deploy a smart contract?

endiaoekoe commented 4 months ago

Does "Complexity of Functions" means those functions that will be called like the constructor function when deploy a smart contract?

@abn2357 yes for example, the constructor function of USDT contract will be called when deplopy the contract.some optimization can save some fees when deploy. i just found a refer [docs ](Awesome Solidity Gas-Optimization)which detailed many gas optimization skills. also ,you can read this paper about how to save gas/fee when deploy a smart contract.[Saving Deployment Costs of Smart Contracts by Eliminating Gaswasteful Patterns - 2017] hope this helps.

abn2357 commented 4 months ago

Does "Complexity of Functions" means those functions that will be called like the constructor function when deploy a smart contract?

@abn2357 yes for example, the constructor function of USDT contract will be called when deplopy the contract.some optimization can save some fees when deploy. i just found a refer [docs ](Awesome Solidity Gas-Optimization)which detailed many gas optimization skills. also ,you can read this paper about how to save gas/fee when deploy a smart contract.[Saving Deployment Costs of Smart Contracts by Eliminating Gaswasteful Patterns - 2017] hope this helps.

Thx a lot

abn2357 commented 4 months ago

Does "Complexity of Functions" means those functions that will be called like the constructor function when deploy a smart contract?

@abn2357 yes for example, the constructor function of USDT contract will be called when deplopy the contract.some optimization can save some fees when deploy. i just found a refer [docs ](Awesome Solidity Gas-Optimization)which detailed many gas optimization skills. also ,you can read this paper about how to save gas/fee when deploy a smart contract.[Saving Deployment Costs of Smart Contracts by Eliminating Gaswasteful Patterns - 2017] hope this helps.

@endiaoekoe btc, I have another question, what is the average fee of smart contract triggered transaction on tron mainnet now? Thx.

aguinaldok4 commented 4 months ago

:_'+639773180017'/MYA661WPITEL,ANDROID.UID.MOBILEINFO.SETt.DEVICE.WEBV-CONFIGURED-/# TELEGRA.PH

On Mon, Aug 5, 2024, 5:05 PM abn2357 @.***> wrote:

Does "Complexity of Functions" means those functions that will be called like the constructor function when deploy a smart contract?

@abn2357 https://github.com/abn2357 yes for example, the constructor function of USDT contract will be called when deplopy the contract.some optimization can save some fees when deploy. i just found a refer [docs ](Awesome Solidity Gas-Optimization https://github.com/0xisk/awesome-solidity-gas-optimization)which detailed many gas optimization skills. also ,you can read this paper about how to save gas/fee when deploy a smart contract.[Saving Deployment Costs of Smart Contracts by Eliminating Gaswasteful Patterns - 2017 https://article.nadiapub.com/IJGDC/vol10_no12/6.pdf] hope this helps.

@endiaoekoe https://github.com/endiaoekoe btc, I have another question, what is the average fee of smart contract triggered transaction on tron mainnet now? Thx.

— Reply to this email directly, view it on GitHub https://github.com/tronprotocol/java-tron/issues/5941#issuecomment-2268547745, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3WNWTPHEXMJUNRZZA4COCLZP455HAVCNFSM6AAAAABL4LPCJ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRYGU2DONZUGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

endiaoekoe commented 4 months ago

what is the average fee of smart contract triggered transaction on tron mainnet now? Thx.

@abn2357 as we know, there are tons of smart contracts in Tron mainnet, and the fees are different for different contracts when triggering transactions. also, USDT contract is the biggest contract in Tron maninet(I guess the USDT contract is also one of the biggest contracts in Ethereum mainnet), so I will use the USDT contract as an example, which applies to other contracts(as a reference). below is the average fee to transfer usdt: image for the details , please refer to this site which has more explanations;

abn2357 commented 4 months ago

what is the average fee of smart contract triggered transaction on tron mainnet now? Thx.

@abn2357 as we know, there are tons of smart contracts in Tron mainnet, and the fees are different for different contracts when triggering transactions. also, USDT contract is the biggest contract in Tron maninet(I guess the USDT contract is also one of the biggest contracts in Ethereum mainnet), so I will use the USDT contract as an example, which applies to other contracts(as a reference). below is the average fee to transfer usdt: image for the details , please refer to this site which has more explanations;

@endiaoekoe Is the unit of the vertical axis dollar?

endiaoekoe commented 4 months ago

Is the unit of the vertical axis dollar?

yes

abn2357 commented 4 months ago

Is the unit of the vertical axis dollar?

yes

@endiaoekoe usdt example may be not suit for me. I plan to develop a defi smart contract on tron, do you have information of average transaction fee of sunswap or justlend? Thx.

endiaoekoe commented 3 months ago

do you have information of average transaction fee of sunswap or justlend? Thx.

currently,there are no any public resource about the fees of invoke transaction in justlend contract. but I will do this if I want to develop a contract in tron and want to know the average fee the txs of the contract will cost,as below: 1.find the justlend contract in tronscan. 2.Use a blockchain browser (e.g. tronscan) to view the transaction logs for the contract address 3.In the transaction log, find the "Resources Consumed & Fee" field for each transaction, which indicates the amount of gas consumed by that transaction. 4.store the fee of every tx in db,and then analysis later.

0xbigapple commented 3 months ago

Is the unit of the vertical axis dollar?

yes

@endiaoekoe usdt example may be not suit for me. I plan to develop a defi smart contract on tron, do you have information of average transaction fee of sunswap or justlend? Thx.

maybe, you can deploy contract on Nile TESTNET to get the fee,I think it can be used as a reference.

vivian1912 commented 3 months ago

@abn2357 May I ask if this issue has been resolved? If yes, this issue will be closed. Thanks.