TRON Developer Hub CN

TRON开发者中心

欢迎来到TRON开发者中心。您将找到全面的指南和文档,以帮助您尽快开始使用TRON Developer Hub,并在遇到困难时提供支持。让我们跳进去吧!

Get Started    

合约开发成本

介绍

任何区块链的智能合约开发都涉及资源支出的开发成本。 但是,在TRON区块链上开发智能合约远比以太坊和类似协议便宜。 本指南以用户友好的格式进行比较。 如果您希望估算开发智能合约的能源成本,请转到 Tron Station ,它有能量和带宽工具可以帮助您。

概要

下表对比了小型合同的开发成本,中型合同以及TRON和以太坊之间的大型合同。 两个示例小合同是简单存储合同和斐波纳契合同。 中型合同示例是一个名为zombiefactory的修改后的加密僵尸合同,而大型合同是另一个名为zombieownership的修改后的加密僵尸合同。 带宽和能量消耗发生的三种情况概括为TRON-1,TRON-2和TRON-3:

图表表示
  • TRON-1:不使用来自冻结代币的任何 带宽能量

  • TRON-1 = 能源费+带宽费

  • TRON-2:仅使用来自冻结代币 免费带宽或带宽


  • TRON-2 = TRON-1 - 免费带宽配额 - 冻结带宽配额

  • TRON-3:使用来自冻结代币的 带宽能量

  • TRON-3 = TRON-2 - 冷冻能源配额

比较图表

表 1
TRX & 以太坊在TRX中的合同开发成本比较

示例

小合同 - a

小合同 - b

中型合同

大型合同

单位

TRON-1

3.834

6.719

47.3

123.118

TRX

TRON-2

3.828

6.711

47.272

123.046

TRX

TRON-3

0

0

0

0

TRX

以太坊

9.757

13.983

73.600

212.019

TRX

表 2
TRON & 以太坊与美元之间的合同开发成本比较

示例

小合同 - a

小合同 - b

中型合同

大型合同

单位

TRON-1

0.088

0.155

1.088

2.831

美元

TRON-2

0.088

0.154

1.087

2.830

美元

TRON-3

0

0

0

0

美元

以太坊

0.224

0.322

1.693

4.876

美元

表 3
TRON & 以太坊在Kwei的合同开发成本比较

用例

小型合同 - a

小型合同 - b

中型合同

大型合同

单位

TRON-1

0.441

0.773

5.439

14.158

Kwei

TRON-2

0.440

0.772

5.436

14.150

Kwei

TRON-3

0

0

0

0

Kwei

以太坊

1.122

1.608

8.464

24.382

Kwei

用于示例计算的转换率来自10/11/2018的平均费率。 转换率如下:

转变

汇率

TRX 到美元

0.023

ETH 到美元

200

Kwei 到 USD

0.2

ETH 到 TRX

8695.7

工具


使用了以下工具:

TRON

编译 & 部署:
转换器:

以太坊

编译 & 部署:
转换器

小型合同示例

简单存储

pragma solidity ^0.4.23;

contract SimpleStorage {
 uint storedData;
 
 function set(uint x) public {
 storedData = x;
 }
 
 function get() public view returns (uint) {
 return storedData;
 }
}

ByteCode:

608060405234801561001057600080fd5b5060bf8061001f6000396000f30060806040526004361060485763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166360fe47b18114604d5780636d4ce63c146064575b600080fd5b348015605857600080fd5b5060626004356088565b005b348015606f57600080fd5b506076608d565b60408051918252519081900360200190f35b600055565b600054905600a165627a7a72305820239acc7b4a09319cfdb7508ca7d60748d30152d2fcb8715af728b2e4d23ad7b90029

字节大小: 444

创建 & 部署合约成本

TRON

  • 总费用3833820 sun(3.834 TRX)
  • 能量使用: 0
  • 能源费用: 3833820 sun
  • 原能量使用: 0 sun
  • 能量使用总计: 38281
  • 净使用量: 0
  • 净费用: 5720 sun

以太坊

  • 总Gas成本: 1122130 Gwei(0.00112213 ETH)

斐波那契

pragma solidity ^0.4.23;

contract Fibonacci {
 
 event Notify(uint input, uint result);
 
 function fibonacci(uint number) public constant returns(uint result) {
 if (number == 0) return 0;
 else if (number == 1) return 1;
 else return Fibonacci.fibonacci(number - 1) + Fibonacci.fibonacci(number - 2);
 }
 
 function fibonacciNotify(uint number) public returns(uint result) {
 result = fibonacci(number);
 emit Notify(number, result);
 }
}

ByteCode

608060405234801561001057600080fd5b5061014f806100206000396000f30060806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633c7fdc70811461005057806361047ff41461007a575b600080fd5b34801561005c57600080fd5b50610068600435610092565b60408051918252519081900360200190f35b34801561008657600080fd5b506100686004356100e0565b600061009d826100e0565b604080518481526020810183905281519293507f71e71a8458267085d5ab16980fd5f114d2d37f232479c245d523ce8d23ca40ed929081900390910190a1919050565b60008115156100f15750600061011e565b81600114156101025750600161011e565b61010e600283036100e0565b61011a600184036100e0565b0190505b9190505600a165627a7a72305820b5d7a97b640c5a8dd2e1014ef53cc75c6b59888e23c306514125eebef96adc140029

字节大小: 734

创建 & 部署成本

TRON

  • 总费用6719410 sun (6.719 TRX)
    • 能量使用: 0
    • 能源费用: 6711100 sun
    • 原能量使用: 0 sun
    • 能量使用总计: 67111
    • 净使用量: 0
    • 净费用: 8310 sun

    以太坊

    • 总Gas成本1607850 Gwei (0.00160785 ETH)

    中型合同示例

    在这里访问zombieownership solidity文件 字节代码
60806040526010600155662386f26fc100006002556201518060035560008054600160a060020a031916331790556107a98061003c6000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632052465e8114610071578063528b7b8f146101355780637bff0a01146101695780638da5cb5b146101c4578063f2fde38b146101d9575b600080fd5b34801561007d57600080fd5b506100896004356101fa565b60408051602080820188905263ffffffff80881693830193909352918516606082015261ffff8085166080830152831660a082015260c080825288519082015287519091829160e08301918a019080838360005b838110156100f55781810151838201526020016100dd565b50505050905090810190601f1680156101225780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b34801561014157600080fd5b5061014d6004356102eb565b60408051600160a060020a039092168252519081900360200190f35b34801561017557600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101c29436949293602493928401919081908401838280828437509497506103069650505050505050565b005b3480156101d057600080fd5b5061014d61033f565b3480156101e557600080fd5b506101c2600160a060020a036004351661034e565b600480548290811061020857fe5b60009182526020918290206003919091020180546040805160026001841615610100026000190190931692909204601f8101859004850283018501909152808252919350918391908301828280156102a15780601f10610276576101008083540402835291602001916102a1565b820191906000526020600020905b81548152906001019060200180831161028457829003601f168201915b505050600184015460029094015492939263ffffffff8082169350640100000000820416915061ffff6801000000000000000082048116916a010000000000000000000090041686565b600560205260009081526040902054600160a060020a031681565b336000908152600660205260408120541561032057600080fd5b610329826103e2565b905060648106900361033b82826104c3565b5050565b600054600160a060020a031681565b600054600160a060020a0316331461036557600080fd5b600160a060020a038116151561037a57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600080826040516020018082805190602001908083835b602083106104185780518252601f1990920191602091820191016103f9565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831061047b5780518252601f19909201916020918201910161045c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020600190049050600254818115156104bb57fe5b069392505050565b6040805160c0810182528381526020808201849052600192820183905260038054420163ffffffff16606084015260006080840181905260a08401819052600480548087018083559183528551805193979692959294919091027f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b019261054d92849201906106e2565b50602082810151600183810191909155604080850151600290940180546060808801516080808a015160a0909a015163ffffffff1990941663ffffffff998a161767ffffffff00000000191664010000000099909216989098021769ffff000000000000000019166801000000000000000061ffff998a1602176bffff0000000000000000000019166a010000000000000000000098909216979097021790559590940360008181526005835286812080543373ffffffffffffffffffffffffffffffffffffffff1990911681179091558152600683528681208054909601909555855181815295860188905285820184815289519487019490945288519096507f88f026aacbbecc90c18411df4b1185fd8d9be2470f1962f192bf84a27d0704b79587958a958a959294909392850192908701918190849084905b838110156106a1578181015183820152602001610689565b50505050905090810190601f1680156106ce5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061072357805160ff1916838001178555610750565b82800160010185558215610750579182015b82811115610750578251825591602001919060010190610735565b5061075c929150610760565b5090565b61077a91905b8082111561075c5760008155600101610766565b905600a165627a7a72305820fb15fb70eb38f8ef38faa6e94485a3f2c3bbbe0aed82f59b2a0bd13c492432890029

字节大小: 4042

## 创建 & 部署成本

### TRON

* **总费用**: **47299680** sun *(47.3 TRX)*
* 能量使用: **0**
* 能量费用: **47272000** sun
* 原能量使用: **0** sun
* 能量使用总计: **472720**
* 净使用量: **0**
* 净费用: **27680** sun

### 以太坊

* **总气体成本**: **8464150** Gwei *(0.00846415 ETH)*

* * *

# 大型合同示例

在这里访问zombieownership solidity文件 <a href="https://github. com/wxue/solidity-cryptozombies/blob/master/contracts/zombieownership. sol" target="_blank"></a>。

**字节代码** 
60806040526010600155662386f26fc100006002556201518060035560008054600160a060020a03191633179055610ba38061003c6000396000f3006080604052600436106100825763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166317a7f4cc81146100875780632052465e146100a4578063528b7b8f146101685780635f4623f11461019c5780637bff0a01146101bd5780638da5cb5b14610216578063f2fde38b1461022b575b600080fd5b34801561009357600080fd5b506100a260043560243561024c565b005b3480156100b057600080fd5b506100bc60043561032d565b60408051602080820188905263ffffffff80881693830193909352918516606082015261ffff8085166080830152831660a082015260c080825288519082015287519091829160e08301918a019080838360005b83811015610128578181015183820152602001610110565b50505050905090810190601f1680156101555780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390f35b34801561017457600080fd5b5061018060043561041e565b60408051600160a060020a039092168252519081900360200190f35b3480156101a857600080fd5b506100a2600160a060020a0360043516610439565b3480156101c957600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100a294369492936024939284019190819084018382808284375094975061047f9650505050505050565b34801561022257600080fd5b506101806104b8565b34801561023757600080fd5b506100a2600160a060020a03600435166104c7565b600754604080517fe98b7f4d000000000000000000000000000000000000000000000000000000008152600481018490529051600092600160a060020a03169163e98b7f4d9160248083019261014092919082900301818787803b1580156102b357600080fd5b505af11580156102c7573d6000803e3d6000fd5b505050506040513d6101408110156102de57600080fd5b50610120015160408051808201909152600581527f6b697474790000000000000000000000000000000000000000000000000000006020820152909150610328908490839061055b565b505050565b600480548290811061033b57fe5b60009182526020918290206003919091020180546040805160026001841615610100026000190190931692909204601f8101859004850283018501909152808252919350918391908301828280156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b505050600184015460029094015492939263ffffffff8082169350640100000000820416915061ffff6801000000000000000082048116916a010000000000000000000090041686565b600560205260009081526040902054600160a060020a031681565b600054600160a060020a0316331461045057600080fd5b6007805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b336000908152600660205260408120541561049957600080fd5b6104a282610799565b90506064810690036104b4828261087a565b5050565b600054600160a060020a031681565b600054600160a060020a031633146104de57600080fd5b600160a060020a03811615156104f357600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008381526005602052604081205481908590600160a060020a0316331461058257600080fd5b600480548790811061059057fe5b906000526020600020906003020192506105a983610a99565b15156105b457600080fd5b600254858115156105c157fe5b0694506002858460010154018115156105d657fe5b04915060405160200180807f6b6974747900000000000000000000000000000000000000000000000000000081525060050190506040516020818303038152906040526040518082805190602001908083835b602083106106485780518252601f199092019160209182019101610629565b51815160209384036101000a60001901801990921691161790526040519190930181900381208951909550899450908301928392508401908083835b602083106106a35780518252601f199092019160209182019101610684565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106107065780518252601f1990920191602091820191016106e7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191614156107495760648206820360630191505b6107886040805190810160405280600681526020017f4e6f4e616d6500000000000000000000000000000000000000000000000000008152508361087a565b61079183610ab2565b505050505050565b600080826040516020018082805190602001908083835b602083106107cf5780518252601f1990920191602091820191016107b0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106108325780518252601f199092019160209182019101610813565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206001900490506002548181151561087257fe5b069392505050565b6040805160c0810182528381526020808201849052600192820183905260038054420163ffffffff16606084015260006080840181905260a08401819052600480548087018083559183528551805193979692959294919091027f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01926109049284920190610adc565b50602082810151600183810191909155604080850151600290940180546060808801516080808a015160a0909a015163ffffffff1990941663ffffffff998a161767ffffffff00000000191664010000000099909216989098021769ffff000000000000000019166801000000000000000061ffff998a1602176bffff0000000000000000000019166a010000000000000000000098909216979097021790559590940360008181526005835286812080543373ffffffffffffffffffffffffffffffffffffffff1990911681179091558152600683528681208054909601909555855181815295860188905285820184815289519487019490945288519096507f88f026aacbbecc90c18411df4b1185fd8d9be2470f1962f192bf84a27d0704b79587958a958a959294909392850192908701918190849084905b83811015610a58578181015183820152602001610a40565b50505050905090810190601f168015610a855780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b600201544264010000000090910463ffffffff16111590565b60035442018160020160046101000a81548163ffffffff021916908363ffffffff16021790555050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610b1d57805160ff1916838001178555610b4a565b82800160010185558215610b4a579182015b82811115610b4a578251825591602001919060010190610b2f565b50610b56929150610b5a565b5090565b610b7491905b80821115610b565760008155600101610b60565b905600a165627a7a72305820056f8fea1ac313d13c4e7f1d9ab97dd7885b2a8b08b63e5b684dcf7fbbd7dc2d0029

字节大小:6078

## 创建 & 部署成本

### 波场

* **总费用**: **123117850** sun *(123.118 TRX)*
* 能量使用: **0**
* 能量费用: **123045800** sun
* 原能量使用: **0** sun 
* 能量使用总计: **1230458**
* 净使用量: **0**
* 净费用: **72050** sun

### 以太坊

* **总气体成本**: **24381820** Gwei *(0.02438182 ETH)*

# 冻结需要多少TRX才能在主网上自由部署?

以下数字来自于2014年10月23日的测试,其中TotalEnergyWeight为2,127,263。

我们从冷冻100 TRX获得的能量是=(100/2127263)* 50,000,000,0000 = 23504380。

获得的能量=为获得能量而冻结的TRX /为在整个网络中获得能量而冻结的总TRX * 50,000,000,000

基于这样的冻结代币池大小,

* 为了部署一份小合同,我们需要冻结2-2.5 TRX;

* 用5-20 TRX冻结足以免费部署中型合约;

* 对于一份大合同,这个数字大约是50 TRX。

**请注意,能量获得(energyLimit)是基于totalEnergyWeight的动态。**

Updated 24 days ago

合约开发成本


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.