波场白皮书

TRON Whitepaper v2.0

作者 Justin Sun · 2017

Introduction

Introduction

1.1 Vision

TRON is an ambitious project dedicated to the establishment of a truly decentralized Internet and its infrastructure. The TRON Protocol, one of the largest blockchain-based operating systems in the world, offers public blockchain support of high throughput, high scalability, and high availability for all Decentralized Applications (DApps) in the TRON ecosystem. The July 2018 acquisition of BitTorrent further cemented TRON’s leadership in pursuing a decentralized ecosystem.
1.2 Background

The introduction of Bitcoin in 2009 revolutionized society’s perception of the traditional financial system in the wake of the Great Recession (2007-2008). As centralized hedge funds and banks collapsed from speculation in opaque financial derivatives, blockchain technology provided a transparent universal ledger from which anybody could glean transaction information. The transactions were cryptographically secured using a Proof of Work (PoW) consensus mechanism, thus preventing double spend issues.

In late 2013, the Ethereum white paper proposed a network in which smart contracts and a Turing-complete Ethereum Virtual Machine (EVM) would allow developers to interact with the network through DApps. However, as transaction volumes in Bitcoin and Ethereum peaked in 2017, it was apparent from the low transaction throughput times and high transaction fees that cryptocurrencies like Bitcoin and Ethereum in their existing state were not scalable for widespread adoption. Thus, TRON was founded and envisioned as an innovative solution to these pressing scalability challenges.

TRON development roadmap phase 1 timeline from July 2017 to June 2018

1.3 History The TRON DAO was established in July 2017 in Singapore. In December 2017, TRON had launched its open source protocol. The Testnet, Blockchain Explorer, and Web Wallet were all launched by March 2018. TRON Mainnet launched shortly afterward in May 2018, marking the Odyssey 2.0 release as a technical milestone. In June 2018, TRON declared its independence with the creation of the Genesis block, along with the July 2018 acquisition of BitTorrent. In October 2018, TRON launched the TRON Virtual Machine (TVM), a complete developers’ toolset, and 360 support system. The TRON roadmap involves combining BitTorrent’s 100 million users with the TRON network via Project Atlas, as well as fostering the developer community to launch exciting new DApps on the TRON network1. 1 V1.0 is available at https://tron.network/static/doc/white_paper_v_1_0.pdf

TRON development roadmap phase 2 timeline from July 2018 to 2019

1.4 Terminology

Address/Wallet An address or wallet consisting of account credentials on the TRON network are generated by a key pair, which consists of a private key and a public key, the latter being derived from the former through an algorithm. The public key is usually used for session key encryption, signature verification, and encrypting data that could be decrypted by a corresponding private key.

ABI An application binary interface (ABI) is an interface between two binary program modules; usually one of these modules is a library or an operating system facility, and the other is a user run program.

API An application programming interface (API) is mainly used for user clients development. With API support, token issuance platforms can also be designed by developers themselves.

Asset In TRON's documents, asset is the same as token, which is also denoted as TRC-10 token.

Bandwidth Points (BP) To keep the network operating smoothly, TRON network transactions use BP as fuel. Each account gets 5000 free daily BP and more can be obtained by freezing TRX for BP. Both TRX and TRC-10 token transfers are normal transactions costing BP. Smart contract deployment and execution transactions consume both BP and Energy.

Block Blocks contain the digital records of transactions. A complete block consists of the magic number, block size, block header, transaction counter, and transaction data.

Block Reward Block production rewards are sent to a sub-account (address/wallet). Super Representatives can claim their rewards on Tronscan or through the API directly.

Block Header A block header is part of a block. TRON block headers contain the previous block’s hash, the Merkle root, timestamp, version, and witness address.

Cold Wallet Cold wallet, also known as offline wallet, keeps the private key completely disconnected from any network. Cold wallets are usually installed on "cold" devices (e.g. computers or mobile phones staying offline) to ensure the security of TRX private key.

DApp Decentralized Application is an App that operates without a centrally trusted party. An application that enables direct interaction/agreements/communication between end users and/or resources without a middleman.

gRPC gRPC (gRPC Remote Procedure Calls) is an open source remote procedure call (RPC) system 2 initially developed at Google. It uses HTTP/2 for transport, Protocol Buffers as the interface description language, and provides features such as authentication, bidirectional streaming and flow control, blocking or nonblocking bindings, and cancellation and timeouts. It generates cross-platform client and server bindings for many languages. Most common usage scenarios include connecting services in microservices style architecture and connecting mobile devices, and browser clients to backend services.

Hot Wallet Hot wallet, also known as online wallet, allows user's private key to be used online, thus it could be susceptible to potential vulnerabilities or interception by malicious actors.

JDK Java Development Kit is the Java SDK used for Java applications. It is the core of Java development, comprising the Java application environment (JVM+Java class library) and Java tools.

KhaosDB TRON has a KhaosDB in the full-node memory that can store all the newly-forked chains generated within a certain period of time and supports witnesses to switch from their own active chain swiftly into a new main chain. See 2.2.2 State Storage for more details.

LevelDB LevelDB was initially adopted with the primary goal to meet the requirements of fast R/W and rapid development. After launching the Mainnet, TRON upgraded its database to an entirely customized one catered to its very own needs. See 2.2.1 Blockchain Storage for more details.

Merkle Root A Merkle root is the hash of all hashes of all transactions included as part of a block in a blockchain network. See 3.1 Delegated Proof of Stake (DPoS) for more details. 2 https://en.wikipedia.org/wiki/GRPC

Public Testnet (Shasta) A version of the network running in a single-node configuration. Developers can connect and test features without worrying about the economic loss. Testnet tokens have no value and anyone can request more from the public faucet.

RPC
3 In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in a different address space (commonly on another computer on a shared network), which is coded as if it were a normal (local) procedure call, without the programmer explicitly coding the details for the remote interaction.

Scalability Scalability is a feature of the TRON Protocol. It is the capability of a system, network, or process to handle a growing amount of work or its potential to be enlarged to accommodate that growth.

SUN SUN replaced drop as the smallest unit of TRX. 1 TRX = 1,000,000 SUN.

Throughput High throughput is a feature of TRON Mainnet. It is measured in Transactions Per Second (TPS), namely the maximum transaction capacity in one second.

Timestamp The approximate time of block production is recorded as Unix timestamp, which is the number of milliseconds that have elapsed since 00:00:00 01 Jan 1970 UTC.

TKC Token configuration.

TRC-10 A standard of crypto token on TRON platform. Certain rules and interfaces are required to follow when holding an initial coin offering on TRON blockchain.

TRX TRX stands for Tronix, which is the official cryptocurrency of TRON.

3 https://en.wikipedia.org/wiki/Remote_procedure_call

介绍

1.1 愿景

TRON 是一个雄心勃勃的项目,致力于建立一个真正去中心化的互联网及其 基础设施。 TRON 协议,最大的基于 blockchain 的操作系统之一 world,为高吞吐量、高可扩展性和高可用性提供公共 blockchain 支持 TRON 生态系统中的所有去中心化应用程序 (DApp)。 2018年7月收购 BitTorrent 进一步巩固了 TRON 在追求去中心化生态系统方面的领导地位。
1.2 背景

2009 年Bitcoin 的推出彻底改变了社会对传统金融的看法 大衰退(2007-2008)之后的系统。作为中心化的对冲基金和银行 由于不透明的金融衍生品投机而崩溃,blockchain 技术提供了 透明的通用分类账,任何人都可以从中收集交易信息。的 使用工作证明(PoW)共识机制以加密方式保护交易, 从而防止双重支出问题。

2013 年底,Ethereum 白皮书提出了一个网络,其中 smart contract 和 图灵完备的 Ethereum 虚拟机 (EVM) 将允许开发人员与 通过 DApp 网络。然而,随着 Bitcoin 和 Ethereum 的交易量在 2017 年达到顶峰, 从低交易吞吐量时间和高交易费用可以明显看出 像 Bitcoin 和 Ethereum 这样的加密货币在其现有状态下无法扩展以供广泛使用 收养。因此,TRON 成立并被设想为解决这些紧迫问题的创新解决方案 可扩展性挑战。

TRON development roadmap phase 1 timeline from July 2017 to June 2018

1.3 历史 TRON DAO 于 2017 年 7 月在新加坡成立。 2017 年 12 月,TRON 有 推出了其开源协议。测试网、区块链浏览器和网络钱包都是 于 2018 年 3 月推出。TRON 主网随后于 2018 年 5 月推出,标志着 Odyssey 2.0 的发布是一个技术里程碑。 2018年6月,TRON宣布独立 随着 Genesis 区块的创建,以及 2018 年 7 月对 BitTorrent 的收购。在 2018 年 10 月,TRON 推出了 TRON 虚拟机 (TVM),这是一个完整的开发人员工具集, 以及360支持系统。 TRON 路线图涉及合并 BitTorrent 的 1 亿用户 通过 Project Atlas 与 TRON 网络合作,并促进开发者社区推出 TRON 网络上令人兴奋的新 DApps1。 1 V1.0 发布于 https://tron.network/static/doc/white_paper_v_1_0.pdf

1.4 术语

地址/钱包 由 TRON 网络上的帐户凭据组成的地址或钱包由 密钥对,由私钥和公钥组成,后者源自前者 通过算法。公钥通常用于会话密钥加密、签名 验证,并对可以通过相应私钥解密的数据进行加密。

ABI 应用程序二进制接口(ABI)是两个二进制程序模块之间的接口;通常 这些模块之一是库或操作系统设施,另一个是用户运行的 程序。

应用程序编程接口 应用程序编程接口(API)主要用于用户客户端开发。具有API 支持,token发行平台也可以由开发者自行设计。

资产 在TRON的文档中,资产与token相同,也表示为TRC-10 token。

带宽点 (BP) 为了保持网络平稳运行,TRON网络交易使用BP作为燃料。每个账户 每日免费获得5000BP,冻结TRX换BP还可获得更多。 TRX 和 TRC-10 token 转账是消耗 BP 的正常交易。 智能合约部署和执行 交易既消耗BP又消耗Energy。

块 区块包含交易的数字记录。一个完整的块由幻数组成, 区块大小、区块头、交易计数器和交易数据。

区块奖励 区块生产奖励发送至子账户(地址/钱包)。超级代表可以 在 Tronscan 上或直接通过 API 领取奖励。

区块头 块头是块的一部分。 TRON 块头包含前一个块的 hash, Merkle 根、时间戳、版本和见证人地址。冷钱包 冷钱包也称为离线钱包,使私钥与任何人完全断开连接。 网络。冷钱包通常安装在“冷”设备上(例如电脑或手机) 保持离线)以保证TRX私钥的安全。

去中心化应用程序 去中心化应用程序是一种在没有集中信任方的情况下运行的应用程序。申请 实现最终用户和/或资源之间的直接交互/协议/通信 没有中间人。

远程过程调用 gRPC(gRPC Remote procedure Calls)是一个开源的远程过程调用(RPC)系统 2 最初是在 Google 开发的。它使用 HTTP/2 进行传输,使用 Protocol Buffers 作为接口 描述语言,并提供身份验证、双向流和流量等功能 控制、阻塞或非阻塞绑定以及取消和超时。它生成 多种语言的跨平台客户端和服务器绑定。最常见的使用场景 包括微服务风格架构中的连接服务和连接移动设备,以及 浏览器客户端到后端服务。

热钱包 热钱包又称在线钱包,允许用户在线使用私钥,因此可以 容易受到潜在漏洞或恶意行为者拦截的影响。

JDK Java Development Kit 是用于 Java 应用程序的 Java SDK。它是Java的核心 开发,包括Java应用环境(JVM+Java类库)和Java 工具。

考斯数据库 TRON 在全节点内存中有一个 KhaosDB,可以存储所有新分叉生成的链 在一定时间内支持见证人快速从自己的活跃链切换 进入新的主链。更多详细信息请参见 2.2.2 状态存储。

水平数据库 LevelDB最初被采用的主要目标是满足快速R/W和快速读取的要求。 发展。主网启动后,TRON 将其数据库升级为完全定制的 一个满足其自身的需要。更多详情请参见2.2.1 区块链存储。

默克尔根 Merkle 根是作为 blockchain 中的块的一部分包含的所有交易的所有 hash 的 hash 网络。有关更多详细信息,请参阅 3.1 委托权益证明 (DPoS)。 2 https://en.wikipedia.org/wiki/GRPC

TRON development roadmap phase 2 timeline from July 2018 to 2019

公共测试网(Shasta) 以单节点配置运行的网络版本。开发者可以连接并测试 功能,无需担心经济损失。测试网 tokens 没有价值,任何人都可以 对公共水龙头提出更多要求。

远程过程调用
3 在分布式计算中,远程过程调用(RPC)是指计算机程序引起 在不同的地址空间(通常在另一台计算机上)执行的过程(子例程) 一个共享网络),它的编码就像一个正常的(本地)过程调用,没有 程序员明确编码远程交互的细节。

可扩展性 可扩展性是 TRON 协议的一项功能。它是系统、网络或流程的能力 处理越来越多的工作或扩大工作量以适应这种增长的潜力。

太阳 SUN取代drop成为TRX的最小单位。 1 TRX = 1,000,000 SUN。

吞吐量 高吞吐量是 TRON 主网的一个特点。它以每秒事务数 (TPS) 来衡量, 即一秒内的最大交易能力。

时间戳 区块生产的大致时间记录为Unix时间戳,即区块生产的数量 自 UTC 时间 1970 年 1 月 1 日 00:00:00 起经过的毫秒数。

TKC 令牌配置。

TRC-10 TRON 平台上的加密货币 token 标准。需要遵循一定的规则和接口 在 TRON blockchain 举行首次代币发行时。

TRX TRX代表Tronix,它是TRON的官方加密货币。

3 https://en.wikipedia.org/wiki/Remote_procedure_call

Architecture

Architecture

TRON adopts a 3-layer architecture divided into Storage Layer, Core Layer, and Application Layer. The TRON protocol adheres to Google Protobuf, which intrinsically supports multi-language extension.

TRON three-layer architecture diagram showing Application Layer Core Layer and Storage Layer

Figure 1: TRON 3-layer Architecture

2.1 Core

There are several modules in the core layer, including smart contracts, account management, and consensus. A stack-based virtual machine is implemented on TRON and an optimized instruction set is used. In order to better support DApp developers, Solidity was chosen as the smart contract 4 language, followed by future support of other advanced languages. In addition, TRON's consensus mechanism is based on Delegated Proof of Stake (DPoS) and many innovations were made in order to meet its unique requirements. 2.2 Storage

TRON designed a unique distributed storage protocol consisting of Block Storage and State Storage. The notion of a graph database was introduced into the design of the storage layer to better meet the need for diversified data storage in the real world. 2.2.1 Blockchain Storage

TRON blockchain storage chooses to use LevelDB, which is developed by Google and proven successful with many companies and projects. It has high performance and supports arbitrary byte arrays as both keys and values, singular get, put and delete, batched put and delete, bi-directional iterators, and simple compression using the very fast Snappy algorithm. 2.2.2 State Storage

TRON has a KhaosDB in the full-node memory that can store all the newly forked chains generated within a certain period of time and supports witnesses to switch from their own active chain swiftly into a new main chain. It can also protect blockchain storage by making it more stable from being terminating abnormally in an intermediate state. 2.3 Application

Developers can create a diverse range of DApps and customized wallets on TRON. Since TRON enables smart contracts to be deployed and executed, the opportunities of utility applications are unlimited. 4 Solidity official documentation: https://solidity.readthedocs.io/

2.4 Protocol

TRON protocol adheres to Google Protocol Buffers , which is a language-neutral, platform-neutral, 5 and extensible way of serializing structured data for use in communications protocols, data storage, and more. 2.4.1 Protocol Buffers

Protocol Buffers (Protobuf) is a flexible, efficient, automated mechanism for serializing structured data, similar to JSON or XML, but much smaller, faster and simpler.

Protobuf (.proto) definitions can be used to generate code for C++, Java, C#, Python, Ruby, Golang, and Objective-C languages through the official code generators. Various third-party implementations are also available for many other languages. Protobuf eases development for clients by unifying the API definitions and also optimizing data transfers. Clients can take the API .proto from TRON’s protocol repository and integrate through the automatically-generated code libraries.

As a comparison, Protocol Buffers is 3 to 10 times smaller and 20 to 100 times faster than XML, with less ambiguous syntax. Protobuf generates data access classes that are easier to use programmatically. 2.4.2 HTTP

TRON Protocol provides a RESTful HTTP API alternative to the Protobuf API. They share the same interface but the HTTP API can be readily used in javascript clients. 2.5 TRON Virtual Machine (TVM)

The TVM is a lightweight, Turing complete virtual machine developed for TRON’s ecosystem. The TVM connects seamlessly with the existing development ecosystem to provide millions of global developers with a custom-built blockchain system that is efficient, convenient, stable, secure, and scalable.
2.6 Decentralized Exchange (DEX)

5 Google Protocol Buffers official documentation: https://developers.google.com/protocol-buffers/

The TRON network natively supports decentralized exchange functions. A decentralized exchange consists of multiple trading pairs. A trading pair (notation “Exchange”) is an Exchange Market between TRC-10 tokens, or between a TRC-10 token and TRX. Any account can create a trading pair between any tokens, even if the same pair already exists on the TRON network. Trading and price fluctuations of the trading pairs follow the Bancor Protocol . The TRON network stipulates that 6 the weights of the two tokens in all trading pairs are equal, so the ratio of their balances is the price between them. For example, consider a trading pair containing two tokens, ABC and DEF. ABC has a balance of 10 million and DEF has a balance of 1 million. Since their weights are equal, 10 ABC = 1 DEF. This means that the ratio of ABC to DEF is 10 ABC per DEF. 2.7 Implementation

The TRON blockchain code is implemented in Java and was originally a fork from EthereumJ.

6 Bancor Protocol official website: https://about.bancor.network/protocol/

架构

TRON采用三层架构,分为存储层、核心层和应用层。 TRON 协议遵循 Google Protobuf,本质上支持多语言 扩展。

TRON three-layer architecture diagram showing Application Layer Core Layer and Storage Layer

图 1:TRON 3 层架构

2.1 核心

核心层有几个模块,包括smart contracts、账户管理、 共识。基于堆栈的虚拟机在 TRON 上实现并优化了指令 集被使用。为了更好地支持DApp开发者,Solidity被选为smart contract 4 语言,其次是未来对其他高级语言的支持。另外,TRON的共识 机制基于委托权益证明 (DPoS),并在以下方面做出了许多创新 以满足其独特的要求。 2.2 存储

TRON 设计了一种独特的分布式存储协议,由块存储和状态组成 存储。在存储层的设计中引入了图数据库的概念 更好地满足现实世界多样化数据存储的需求。 2.2.1 区块链存储

TRON blockchain 存储选择使用LevelDB,由Google开发并经过验证 与许多公司和项目取得成功。高性能,支持任意字节 数组作为键和值,单一获取、放置和删除,批量放置和删除,双向 迭代器,以及使用非常快的 Snappy 算法的简单压缩。 2.2.2 状态存储

TRON 在全节点内存中有一个 KhaosDB,可以存储所有新分叉的链 在一定时间内支持见证人快速从自己的活跃链切换 进入新的主链。它还可以通过使其更加稳定来保护 blockchain 存储。 在中间状态异常终止。 2.3 应用

开发者可以在TRON上创建各种DApp和定制钱包。自 TRON 起 使 smart contracts 能够被部署和执行,实用程序应用程序的机会是 无限。 4 Solidity 官方文档:https://solidity.readthedocs.io/

2.4 协议

TRON 协议遵循 Google Protocol Buffers ,这是一种语言中立、平台中立的协议, 5 以及序列化结构化数据的可扩展方式,用于通信协议、数据存储、 等等。 2.4.1 协议缓冲区

Protocol Buffers (Protobuf) 是一种灵活、高效、自动化的机制,用于序列化结构化数据 data,类似于 JSON 或 XML,但更小、更快、更简单。

Protobuf (.proto) 定义可用于生成 C++、Java、C#、Python、Ruby、 通过官方代码生成器生成 Golang 和 Objective-C 语言。各种第三方 还可以用于许多其他语言的实现。 Protobuf 简化了开发 通过统一 API 定义并优化数据传输来为客户端提供服务。客户可以使用API 来自 TRON 协议存储库的 .proto 并通过自动生成的代码进行集成 图书馆。

相比之下,Protocol Buffers 比 XML 小 3 到 10 倍,速度快 20 到 100 倍, 具有更少歧义的语法。 Protobuf 生成更易于使用的数据访问类 以编程方式。 2.4.2 超文本传输协议

TRON 协议提供了 Protobuf API 的 RESTful HTTP API 替代方案。他们有共同点 接口,但 HTTP API 可以很容易地在 javascript 客户端中使用。 2.5 TRON 虚拟机 (TVM)

TVM 是为 TRON 生态系统开发的轻量级图灵完备虚拟机。的 TVM与现有开发生态系统无缝连接,为全球数百万用户提供 为开发者定制高效、便捷、稳定、安全的blockchain系统 可扩展。
2.6 去中心化交易所(DEX)

5 Google Protocol Buffers 官方文档:https://developers.google.com/protocol-buffers/TRON网络原生支持去中心化交易功能。去中心化交易所 由多个交易对组成。交易对(符号“交易所”)是一个交易市场 TRC-10 token 之间,或 TRC-10 token 和 TRX 之间。任何账户都可以创建交易 任何 token 之间的对,即使 TRON 网络上已存在相同的对。贸易和 交易对的价格波动遵循Bancor协议。 TRON 网络规定 6 所有交易对中两个token的权重相等,所以它们的余额之比就是价格 他们之间。例如,考虑一个包含两个 token、ABC 和 DEF 的交易对。 ABC 有 余额为1000万,DEF余额为100万。由于它们的权重相等,因此 10 ABC = 1 防御。这意味着 ABC 与 DEF 的比率为 10 ABC/DEF。 2.7 实施

TRON blockchain 代码是用 Java 实现的,最初是 EthereumJ 的分支。

6 Bancor协议官网:https://about.bancor.network/protocol/

Consensus

Consensus

3.1 Delegated Proof of Stake (DPoS)

The earliest consensus mechanism is the Proof of Work (PoW) consensus mechanism. This protocol is currently implemented in Bitcoin and Ethereum . In PoW systems, transactions 7 8 broadcast through the network are grouped together into nascent blocks for miner confirmation. The confirmation process involves hashing transactions using cryptographic hashing algorithms until a merkle root has been reached, creating a merkle tree:

Figure 2: 8 TRX transactions are hashed into the merkle root. This merkle root is then included in the block header, which is attached to the previously confirmed blocks to form a blockchain. This allows for easy and transparent tracking of transactions, timestamps, and other related information.

7 Bitcoin whitepaper: https://bitcoin.org/bitcoin.pdf 8 Ethereum whitepaper: https://github.com/ethereum/wiki/wiki/White-Paper

Cryptographic hashing algorithms are useful in network attack prevention because they possess several properties :
9

● Input/Output length size​ - The algorithm can pass in an input of any length in size, and outputs a fixed length hash value.
● Efficiency​ - The algorithm is relatively easy and fast to compute.
● Preimage resistance​ - For a given output ​z​, it is impossible to find any input ​x​ such that h(x) =​ ​z​. In other words, the hashing algorithm ​h(x)​ is a one-way function in which only the output can be found, given an input. The reverse is not possible.
● Collision resistance​ - It is computationally infeasible to find any pairs \(x_1 \neq x_2\) such that \(h(x_1) = h(x_2)\). In other words, the probability of finding two different inputs hashing to the same output is extremely low. This property also implies ​second preimage resistance​.
● Second preimage resistance​ - Given ​x​1​, and thus ​h(x​1​)​, it is computationally infeasible to find any ​x​2​ such that ​h(x​1​) = h(x​2​)​. While this property is similar to ​collision resistance​, the property differs in that it is saying an attacker with a given ​x​1​ will find it computationally infeasible to find any ​x​2​ hashing to the same output.
● Deterministic​ - maps each input to one and only one output. ● Avalanche effect​ - a small change in the input results in an entirely different output.

These properties give the cryptocurrency network its intrinsic value by ensuring attacks do not compromise the network. When miners confirm a block, they are rewarded tokens as a built-in incentive for network participation. However, as the global cryptocurrency market capitalization steadily increased, the miners became centralized and focused their computing resources on hoarding tokens as assets, rather than for network participation purposes. CPU miners gave way to GPUs, which in turn gave way to powerful ASICs. In one notable study, the total power consumption of Bitcoin mining has been estimated to be as high as 3 GW , comparable to Ireland’s 10 power consumption. This same study projected total power consumption to reach 8 GW in the near future.

To solve the energy waste issue, the Proof of Stake (PoS) consensus mechanism was proposed by many new networks. In PoS networks, token holders lock their token balances to become block validators. The validators take turns proposing and voting on the next block. However, the problem with standard PoS is that validator influence correlates directly to the amount of tokens locked up. This results in parties hoarding large amounts of the network’s base currency wielding undue influence in the network ecosystem.

The TRON consensus mechanism uses an innovative Delegated Proof of Stake system in which 27 Super Representatives (SRs) produce blocks for the network. Every 6 hours, TRX account holders who freeze their accounts can vote for a selection of SR candidates, with the top 27 candidates deemed the SRs. Voters may choose SRs based on criteria such as projects sponsored by SRs to 9 PAAR, C., PELZL, J., ​Understanding Cryptography: A Textbook for Students and Practitioners​, 2010 ed. Springer-Verlag Berlin Heidelberg, 2010.
10 https://www.sciencedirect.com/science/article/pii/S2542435118301776

increase TRX adoption, and rewards distributed to voters. This allows for a more democratized and decentralized ecosystem. SRs’ accounts are normal accounts, but their accumulation of votes allows them to produce blocks. With the low throughput rates of Bitcoin and Ethereum due to their PoW consensus mechanism and scalability issues, TRON’s DPoS system offers an innovative mechanism resulting in 2000 TPS compared to Bitcoin’s 3 TPS and Ethereum’s 15 TPS.

The TRON protocol network generates one block every three seconds, with each block awarding 32 TRX to Super Representatives. A total of 336,384,000 TRX will be awarded annually to the 27 SRs. Each time an SR finishes block production, rewards are sent to a sub-account in the super-ledger. SRs can check, but not directly make use of these TRX tokens. A withdrawal can be made by each SR once every 24 hours, transferring the rewards from the sub-account to the specified SR account.

The three types of nodes on the TRON network are Witness Node, Full Node, and Solidity Node. Witness nodes are set up by SRs and are mainly responsible for block production and proposal creation/voting. Full nodes provide APIs and broadcast transactions and blocks. Solidity nodes sync blocks from other Full Nodes and also provide indexable APIs.

共识

3.1 委托权益证明 (DPoS)

最早的共识机制是工作量证明(PoW)共识机制。这个 协议目前在 Bitcoin 和 Ethereum 中实现。在 PoW 系统中,交易 7 8 通过网络广播的数据被分组为新生块以供矿工确认。的 确认过程涉及使用加密 hashing 算法进行 hashing 交易,直到 已达到默克尔根,创建默克尔树:

图 2:8 个 TRX 交易被 hash 写入 Merkle 根中。然后这个默克尔根被包含在区块头中, 附加到之前确认的块上,形成blockchain。这样可以轻松、透明地跟踪 交易、时间戳和其他相关信息。

7 Bitcoin 白皮书:https://bitcoin.org/bitcoin.pdf 8 Ethereum 白皮书:https://github.com/ethereum/wiki/wiki/White-Paper

加密 hashing 算法在网络攻击预防中非常有用,因为它们具有 几个属性:
9

● 输入/输出长度大小​ - 该算法可以传入任意长度大小的输入,并且 输出固定长度 hash 值。
● 效率 - 该算法计算起来相对简单且快速。
● 原像抗性 - 对于给定的输出​z​,不可能找到任何输入​x​,使得 h(x) =​ ​z​。换句话说,hashing 算法​h(x)​ 是一种单向函数,其中仅 给定输入,可以找到输出。反过来是不可能的。
● 抗碰撞性 - 在计算上无法找到任何对 ​x​1 ​≠ x​2​ ​使得​h(x​1​) = h(x​2​)​.换句话说,找到两个不同输入 hashing 到同一输入的概率 产量极低。该属性还意味着​第二原像抵抗​。
● 第二原像抗性 - 给定​x​1​,因此​h(x​1​)​,在计算上是不可行的 找到任意​x​2​,使得​h(x​1​) = h(x​2​)​。虽然此属性类似于​防撞​性​,但 属性的不同之处在于,它表示具有给定​x​1​的攻击者将通过计算找到它 无法找到任何​x​2​ hashing 到相同的输出。
● 确定性​ - 将每个输入映射到一个且仅一个输出。 ● Avalanche 效果​ - 输入的微小变化会导致完全不同的输出。

这些特性确保加密货币网络不会受到攻击,从而赋予其内在价值。 危害网络。当矿工确认一个区块时,他们将获得 tokens 作为内置奖励 网络参与的激励。然而,随着全球加密货币市值 稳步增长,矿工变得中心化,将计算资源集中在 囤积 token 作为资产,而不是用于网络参与目的。 CPU矿工让位于 GPU 又让位于强大的 ASIC。在一项著名的研究中,总功率 Bitcoin 采矿消耗量估计高达 3 吉瓦,与爱尔兰的消耗量相当 10 功耗。该研究预计不久的将来总功耗将达到 8 GW 未来。

为了解决能源浪费问题,权益证明(PoS)共识机制被提出 许多新网络。在 PoS 网络中,token 持有者锁定其 token 余额以成为区块 validators。 validator 轮流对下一个区块进行提议和投票。然而,问题 对于标准 PoS 来说,validator 的影响力与锁定的 token 数量直接相关。 这导致各方囤积大量网络基础货币并过度使用 在网络生态系统中的影响力。

TRON 共识机制采用创新的委托权益证明系统,其中 27 超级代表(SR)为网络生产区块。每 6 小时,TRX 账户持有者 冻结账户的人可以投票选出 SR 候选人,其中排名前 27 的候选人 视为 SR。选民可以根据 SR 赞助的项目等标准来选择 SR 9 PAAR, C., PELZL, J.,《理解密码学:学生和从业者教科书》,2010 年版。 柏林施普林格出版社海德堡,2010。
10https://www.sciencedirect.com/science/article/pii/S2542435118301776提高 TRX 的采用率,并向选民分配奖励。这使得更加民主化和 去中心化的生态系统。 SR的账户是普通账户,但是他们的投票是累积的 允许他们生产区块。由于 Bitcoin 和 Ethereum 的吞吐率较低, PoW共识机制和可扩展性问题,TRON的DPoS系统提供了一种创新的 机制导致 2000 TPS 与 Bitcoin 的 3 TPS 和 Ethereum 的 15 TPS 相比。

TRON 协议网络每三秒生成一个区块,每个区块奖励 32 TRX 给超级代表。每年将向 27 名 SR 奖励总计 336,384,000 TRX。 每次SR完成区块生产时,奖励都会发送到超级账本的子账户中。 SR 可以检查,但不能直接使用这些 TRX token。每人均可提款 每24小时SR一次,将子账号的奖励转入指定SR 帐户。

TRON网络上的三种类型的节点是见证节点、完整节点和Solidity节点。 见证节点由SR设立,主要负责区块生产和提案 创作/投票。全节点提供API并广播交易和区块。 Solidity 节点同步 来自其他完整节点的块,还提供可索引的 API。

Account

Account

4.1 Types

The three types of accounts in the TRON network are regular accounts, token accounts, and contract accounts.

1. Regular accounts are used for standard transactions.
2. Token accounts are used for storing TRC-10 tokens.
3. Contract accounts are smart contract accounts created by regular accounts and can be triggered by regular accounts as well. 4.2 Creation

There are three ways to create a TRON account:

1. Create a new account through API 2. Transfer TRX into a new account address 3. Transfer any TRC-10 token into a new account address

An offline key-pair consisting of an address (public key) and a private key, and not recorded by the TRON network, can also be generated. The user address generation algorithm consists of generating a key-pair and then extracting the public key (64-byte byte array representing x, y coordinates). Hash the public key using the SHA3-256 function (the SHA3 protocol adopted is KECCAK-256) and extract the last 20 bytes of the result. Add 41 to the beginning of the byte array and ensure the initial address length is 21 bytes. Hash the address twice using SHA3-256 function and take the first 4 bytes as verification code. Add the verification code to the end of the initial address and obtain the address in base58check format through base58 encoding. An encoded Mainnet address begins with T and is 34 bytes in length. 4.3 Structure

The three different account types are Normal, AssetIssue, and Contract. An Account contains 7 parameters:

1. account_name​: the name for this account – e.g. BillsAccount.
2. type​: what type of this account is – e.g. 0 (stands for type ‘Normal’).
3. balance​: balance of this account – e.g. 4213312.

4. vote​: received votes on this account – e.g. {(“0x1b7w…9xj3”,323), (“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}.
5. asset​: other assets expected TRX in this account – e.g. {<“WishToken”, 66666>, <”Dogie”, 233>}. 6. latest_operation_time​: the latest operation time of this account.

Protobuf data structure: message​ ​Account​ {
​message​ ​Vote​ {

​bytes​ vote_address = ​1​;

​int64​ vote_count = ​2​;

} ​bytes​ accout_name = ​1​;
AccountType type = ​2​;
​bytes​ address = ​3​;
​int64​ balance = ​4​;
​repeated​ Vote votes = ​5​;
map<​string​, ​int64​> asset = ​6​; ​int64​ latest_operation_time = ​10​; }

enum​ ​AccountType​ {
Normal = ​0​;
AssetIssue = ​1​;
Contract = ​2​; }

帐户

4.1 类型

TRON 网络中的三种帐户类型是常规帐户、token 帐户和 合约账户。

1. 常规账户用于标准交易。
2. 令牌账户用于存储 TRC-10 tokens。
3. 合约账户是由普通账户创建的 smart contract 账户,可以 也由常规帐户触发。 4.2 创建

创建 TRON 帐户的方法有以下三种:

1. 通过API创建新账户 2. 将TRX转入新账户地址 3. 将任何 TRC-10 token 转入新帐户地址

离线密钥对,由地址(公钥)和私钥组成,且未被记录。 TRON网络,也可以生成。用户地址生成算法包括 生成密钥对,然后提取公钥(代表 x, y 的 64 字节字节数组 坐标)。使用SHA3-256函数对公钥进行哈希处理(采用的SHA3协议是 KECCAK-256)并提取结果的最后 20 个字节。将 41 添加到字节数组的开头 并保证起始地址长度为21字节。使用 SHA3-256 函数对地址进行两次哈希处理 并取前4个字节作为验证码。将验证码添加到初始的末尾 地址,通过base58编码得到base58check格式的地址。一个编码的 主网地址以T开头,长度为34字节。 4.3 结构

三种不同的账户类型是普通账户、资产发行账户和合约账户。一个账户包含 7 个 参数:

1. account_name​:此帐户的名称 – 例如账单帐户。
2. 类型​:该帐户的类型 - 例如0(代表“正常”类型)。
3. 余额​:该账户的余额 – 例如4213312。

4. 投票​:收到此帐户的投票 – 例如{(“0x1b7w…9xj3”,323), (“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}。
5. 资产​:此账户中预期 TRX 的其他资产 – 例如{<“WishToken”, 66666>, <“Dogie”, 233>}。 6. latest_operation_time​:该账户的最新操作时间。

Protobuf data structure: message​ ​Account​ {
​message​ ​Vote​ {

​bytes​ vote_address = ​1​;

​int64​ vote_count = ​2​;

} ​bytes​ accout_name = ​1​;
AccountType type = ​2​;
​bytes​ address = ​3​;
​int64​ balance = ​4​;
​repeated​ Vote votes = ​5​;
map<​string​, ​int64​> asset = ​6​; ​int64​ latest_operation_time = ​10​; }

enum​ ​AccountType​ {
Normal = ​0​;
AssetIssue = ​1​;
Contract = ​2​; }

Block

Block

A block typically contains a block header and several transactions.

Protobuf data structure: message​ ​Block​ {
BlockHeader block_header = ​1​; ​repeated​ Transaction transactions = ​2​; } 5.1 Block Header

A block header contains ​raw_data​, ​witness_signature​, and ​blockID​.

Protobuf data structure: message​ ​BlockHeader​ {
​message​ ​raw​ {

​int64​ timestamp = ​1​;

​bytes​ txTrieRoot = ​2​; 
​bytes​ parentHash = ​3​;

​uint64​ number = ​4​;  
​uint64​ version = ​5​;

​bytes​ witness_address = ​6​;

} ​bytes​ witness_signature = ​2​; ​bytes​ blockID = ​3​;
} 5.1.1 Raw Data

Raw data is denoted as ​raw_data​ in Protobuf. It contains the raw data of a message, containing 6 parameters:

1. timestamp​: timestamp of this message – e.g. 1543884429000. 2. txTrieRoot​: the Merkle Tree’s Root – e.g. 7dacsa…3ed. 3. parentHash​: the hash of the last block – e.g. 7dacsa…3ed. 4. number​: the block height – e.g. 4638708. 5. version​: reserved – e​.g. 5.

Block header and Merkle tree structure showing how TRX transactions are hashed into the Merkle root

6. witness_address​: the address of the witness packed in this block – e.g. 41928c...4d21. 5.1.2 Witness Signature

Witness signature is denoted as ​witness_signature​ in Protobuf, which is the signature for this block header from the witness node. 5.1.3 Block ID

Block ID is denoted as ​blockID​ in Protobuf. It contains the atomic identification of a block. A Block ID contains 2 parameters: 1. hash​: the hash of block. 2. number​: the hash and height of the block. 5.2 Transaction 5.2.1 Signing

TRON’s transaction signing process follows a standard ECDSA cryptographic algorithm, with a SECP256K1 selection curve. A private key is a random number, and the public key is a point on the elliptic curve. The public key generation process consists of first generating a random number as a private key, and then multiplying the base point of the elliptic curve by the private key to obtain the public key. When a transaction occurs, the transaction raw data is first converted into byte format. The raw data then undergoes SHA-256 hashing. The private key corresponding to the contract address then signs the result of the SHA256 hash. The signature result is then added to the transaction.
5.2.2 Bandwidth Model

Ordinary transactions only consume bandwidth points, but smart contract operations consume both energy and bandwidth points. There are two types of bandwidth points available. Users can gain bandwidth points from freezing TRX, while 5000 free bandwidth points are also available daily.

When a TRX transaction is broadcast, it is transmitted and stored in the form of a byte array over the network. Bandwidth Points consumed by one transaction = number of transaction bytes multiplied by bandwidth points rate. For example, if the byte array length of a transaction is 200, then the transaction consumes 200 bandwidth points. However, if a TRX or token transfer results in the target account being created, then only the bandwidth points consumed to create the account will be deducted, and additional bandwidth points will not be deducted. In an account creation scenario, the network will first consume the bandwidth points that the transaction initiator gained

from freezing TRX. If this amount is insufficient, then the network consumes the transaction initiator’s TRX.

In standard TRX transfer scenarios from one TRX account to another, the network first consumes the bandwidth points gained by the transaction initiator for freezing TRX. If that is insufficient, it then consumes from the free 5000 daily bandwidth points. If that is still not enough, then the network consumes the TRX of the transaction initiator. The amount is calculated by the number of bytes in the transaction multiplied by 10 SUN. Thus, for most TRX holders who may not necessarily freeze their TRX to participate in SR voting, the first step is automatically skipped (since TRX balance frozen = 0) and the 5000 daily free bandwidth powers the transaction.

For TRC-10 token transfers, the network first verifies whether the total free bandwidth points of the issued token asset are sufficient. If not, the bandwidth points obtained from freezing TRX are consumed. If there is still not enough bandwidth points, then it consumes the TRX of the transaction initiator.

5.2.3 Fee

TRON network generally does not charge fees for most transactions, however, due to system restrictions and fairness, bandwidth usage and transactions do take in certain fees.

Fee charges are broken down into the following categories: 1. Normal transactions cost bandwidth points. Users can use the free daily bandwidth points (5000) or freeze TRX to obtain more. When bandwidth points are not enough, TRX will be used directly from the sending account. The TRX needed is the number of bytes * 10 SUN. 2. Smart contracts cost energy (Section 6) but will also need bandwidth points for the transaction to be broadcasted and confirmed. The bandwidth cost is the same as above. 3. All query transactions are free. It doesn’t cost energy or bandwidth.

TRON network also defines a set of fixed fees for the following transactions: 1. Creating a witness node: 9999 TRX 2. Issuing a TRC-10 token: 1024 TRX 3. Creating a new account: 0.1 TRX 4. Creating an exchange pair: 1024 TRX 5.2.4 Transaction as Proof of Stake (TaPoS)

TRON uses TaPoS to ensure the transactions all confirm the main blockchain, while making it difficult to forge counterfeit chains. In TaPoS, the networks require each transaction include part of the hash of a recent block header. This requirement prevents transactions from being replayed on forks not including the referenced block, and also signals the network that a particular user and their

stake are on a specific fork. This consensus mechanism protects the network against Denial of Service, 51%, selfish mining, and double spend attacks.
5.2.5 Transaction Confirmation

A transaction is included in a future block after being broadcast to the network. After 19 blocks are mined on TRON (including its own block), the transaction is confirmed. Each block is produced by one of the top 27 Super Representatives in a round robin fashion. Each block takes ~3 seconds to be mined on the blockchain. Time may slightly vary for each Super Representative due to network conditions and machine configurations. In general, a transaction is considered fully confirmed after ~1 minute. 5.2.6 Structure

Transaction APIs consist of the following functions: message​ ​Transaction​ { ​message​ ​Contract​ { ​enum​ ​ContractType​ { AccountCreateContract = ​0​; // Create account/wallet TransferContract = ​1​; // Transfer TRX TransferAssetContract = ​2​; // Transfer TRC10 token VoteWitnessContract = ​4​; // Vote for Super Representative (SR) WitnessCreateContract = ​5​; // Create a new SR account AssetIssueContract = ​6​; // Create a new TRC10 token WitnessUpdateContract = ​8​; // Update SR information ParticipateAssetIssueContract = ​9​; // Purchase TRC10 token AccountUpdateContract = ​10​; // Update account/wallet information FreezeBalanceContract = ​11​; // Freeze TRX for bandwidth or energy UnfreezeBalanceContract = ​12​; // Unfreeze TRX WithdrawBalanceContract = ​13​; // Withdraw SR rewards, once per day UnfreezeAssetContract = ​14​; // Unfreeze TRC10 token UpdateAssetContract = ​15​; // Update a TRC10 token’s information ProposalCreateContract = ​16​; // Create a new network proposal by any SR ProposalApproveContract = ​17​; // SR votes yes for a network proposal ProposalDeleteContract = ​18​; // Delete a network proposal by owner CreateSmartContract = ​30​; // Deploy a new smart contract TriggerSmartContract = ​31​; // Call a function on a smart contract GetContract = ​32​; // Get an existing smart contract UpdateSettingContract = ​33​; // Update a smart contract’s parameters ExchangeCreateContract = ​41​; // Create a token trading pair on DEX ExchangeInjectContract = ​42​; // Inject funding into a trading pair

ExchangeWithdrawContract = ​43​; // Withdraw funding from a trading pair ExchangeTransactionContract = ​44​; // Perform token trading UpdateEnergyLimitContract = ​45​; // Update origin_energy_limit on a smart contract } } }

区块

一个区块通常包含一个区块头和多个交易。

Protobuf data structure: message​ ​Block​ {
BlockHeader block_header = ​1​; ​repeated​ Transaction transactions = ​2​; } 5.1 区块头

区块头包含​raw_data​、​witness_signature​和​blockID​。

Protobuf data structure: message​ ​BlockHeader​ {
​message​ ​raw​ {

​int64​ timestamp = ​1​;

​bytes​ txTrieRoot = ​2​; 
​bytes​ parentHash = ​3​;

​uint64​ number = ​4​;  
​uint64​ version = ​5​;

​bytes​ witness_address = ​6​;

} ​bytes​ witness_signature = ​2​; ​bytes​ blockID = ​3​;
} 5.1.1 原始数据

原始数据在 Protobuf 中表示为​raw_data​。它包含一条消息的原始数据,包含6 参数:

1. 时间戳​:该消息的时间戳 – 例如1543884429000。 2. txTrieRoot​:Merkle 树的根 – 例如7dacsa…3ed。 3. ParentHash​:最后一个块的 hash – 例如7dacsa…3ed。 4. number​:区块高度 – 例如4638708。 5. 版本​:保留 – 例如5.

Block header and Merkle tree structure showing how TRX transactions are hashed into the Merkle root

6. 证人地址​:包含在该块中的证人的地址 - 例如41928c...4d21。 5.1.2 见证人签名

见证人签名在 Protobuf 中表示为​witness_signature​,即为此的签名 来自见证节点的块头。 5.1.3 区块ID

块 ID 在 Protobuf 中表示为​blockID​。它包含块的原子标识。一个街区 ID包含2个参数: 1. hash​:区块的hash。 2. number​:块的 hash 和高度。 5.2 交易 5.2.1 签名

TRON 的交易签名过程遵循标准 ECDSA 加密算法,具有 SECP256K1选择曲线。私钥是一个随机数,公钥是随机数上的一个点 椭圆曲线。公钥生成过程包括首先生成一个随机数作为 私钥,然后将椭圆曲线的基点与私钥相乘,得到 公钥。当交易发生时,交易原始数据首先被转换为字节格式。 然后原始数据经过 SHA-256 hashing。合约对应的私钥 地址然后对 SHA256 hash 的结果进行签名。然后将签名结果添加到 交易。
5.2.2 带宽模型

普通交易只消耗带宽点,但 smart contract 操作则两者都消耗 能量和带宽点。有两种类型的可用带宽点。用户可以获得 冻结TRX的带宽点,同时每天还有5000个免费带宽点。

当TRX交易被广播时,它以字节数组的形式传输并存储在 网络。一笔交易消耗的带宽点数=交易字节数 乘以带宽点数率。例如,如果一笔交易的字节数组长度为200, 那么该交易消耗200个带宽点。但是,如果 TRX 或 token 传输导致 正在创建的目标帐户,则仅消耗创建帐户的带宽点 会被扣除,额外的带宽点不会被扣除。在帐户创建中 场景下,网络会首先消耗交易发起者获得的带宽点冷冻TRX。如果该金额不足,则网络将消耗该交易 发起者的TRX。

在从一个 TRX 账户到另一个 TRX 账户的标准 TRX 转账场景中,网络首先消耗 交易发起方冻结TRX获得的带宽积分。如果这还不够,那么 每天消耗5000个免费带宽点。如果这还不够,那么网络 消耗交易发起者的TRX。金额按字节数计算 交易额乘以 10 SUN。因此,对于大多数不一定会冻结的 TRX 持有者来说 自己的TRX参与SR投票,第一步会自动跳过(因为TRX余额 freeze = 0),每日 5000 个免费带宽为交易提供动力。

对于 TRC-10 token 传输,网络首先验证该传输的总可用带宽点是否为 发行 token 资产就足够了。如果不是,则冻结TRX获得的带宽点为 消耗了。如果仍然没有足够的带宽点,则消耗交易的TRX 发起者。

5.2.3 费用

TRON 网络一般不对大多数交易收取费用,但是,由于系统原因 限制和公平性、带宽使用和交易确实需要收取一定的费用。

费用分为以下几类: 1. 正常交易会消耗带宽点。用户可以使用每日免费带宽点 (5000)或冻结TRX以获得更多。当带宽点不够时,TRX将被 直接从发送帐户使用。所需的TRX是字节数*10 SUN。 2. 智能合约会消耗能源(第 6 节),但也需要带宽点 交易被广播和确认。带宽成本与上面相同。 3. 所有查询交易都是免费的。它不消耗能源或带宽。

TRON 网络还为以下交易定义了一组固定费用: 1. 创建见证节点:9999 TRX 2. 发行 TRC-10 token:1024 TRX 3. 创建新账户:0.1 TRX 4. 创建交换对:1024 TRX 5.2.4 交易作为权益证明(TaPoS)

TRON 使用 TaPoS 来确保交易全部确认主 blockchain,同时使其 难以伪造假冒链条。在 TaPoS 中,网络要求每笔交易都包含以下部分: 最近区块头的 hash 。此要求可防止交易重播 分叉不包括引用的块,并且还向网络发出信号,表明特定用户及其权益位于特定的分叉上。这种共识机制可以保护网络免受拒绝 服务,51%,自私挖矿,双花攻击。
5.2.5 交易确认

交易在广播到网络后包含在未来的区块中。 19个区块之后 在 TRON (包括其自己的区块)上开采,交易已确认。每个块都是由 循环赛方式中排名前27位的超级代表之一。每个区块大约需要 3 秒的时间 在 blockchain 上开采。由于网络原因,每个超级代表的时间可能略有不同 条件和机器配置。一般来说,交易在以下时间后才被视为完全确认: 〜1分钟。 5.2.6 结构

Transaction APIs consist of the following functions: message​ ​Transaction​ { ​message​ ​Contract​ { ​enum​ ​ContractType​ { AccountCreateContract = ​0​; // Create account/wallet TransferContract = ​1​; // Transfer TRX TransferAssetContract = ​2​; // Transfer TRC10 token VoteWitnessContract = ​4​; // Vote for Super Representative (SR) WitnessCreateContract = ​5​; // Create a new SR account AssetIssueContract = ​6​; // Create a new TRC10 token WitnessUpdateContract = ​8​; // Update SR information ParticipateAssetIssueContract = ​9​; // Purchase TRC10 token AccountUpdateContract = ​10​; // Update account/wallet information FreezeBalanceContract = ​11​; // Freeze TRX for bandwidth or energy UnfreezeBalanceContract = ​12​; // Unfreeze TRX WithdrawBalanceContract = ​13​; // Withdraw SR rewards, once per day UnfreezeAssetContract = ​14​; // Unfreeze TRC10 token UpdateAssetContract = ​15​; // Update a TRC10 token’s information ProposalCreateContract = ​16​; // Create a new network proposal by any SR ProposalApproveContract = ​17​; // SR votes yes for a network proposal ProposalDeleteContract = ​18​; // Delete a network proposal by owner CreateSmartContract = ​30​; // Deploy a new smart contract TriggerSmartContract = ​31​; // Call a function on a smart contract GetContract = ​32​; // Get an existing smart contract UpdateSettingContract = ​33​; // Update a smart contract’s parameters ExchangeCreateContract = ​41​; // Create a token trading pair on DEX ExchangeInjectContract = ​42​; // Inject funding into a trading pair

ExchangeWithdrawContract = ​43​; // Withdraw funding from a trading pair ExchangeTransactionContract = ​44​; // Perform token trading UpdateEnergyLimitContract = ​45​; // Update origin_energy_limit on a smart contract } } }

TRON Virtual Machine

TRON Virtual Machine

6.1 Introduction

TRON Virtual Machine (TVM) is a lightweight, Turing complete virtual machine developed for the TRON's ecosystem. Its goal is to provide a custom-built blockchain system that is efficient, convenient, stable, secure and scalable.

TVM initially forked from EVM and can connect seamlessly with the existing solidity smart contract 11 development ecosystem. Based on that, TVM additionally supports DPoS consensus.

TVM employs the concept of Energy. Different from the Gas mechanism on EVM, operations of transactions and smart contracts on TVM are free, with no TRX consumed. Technically, executable computation capacity on TVM is not restricted by total holding amount of tokens. 6.2 Workflow

The compiler first translates the Solidity smart contract into bytecode readable and executable on the TVM. The TVM then processes data through opcode, which is equivalent to operating the logic of a stack-based finite state machine. Finally, the TVM accesses blockchain data and invokes External Data Interface through the Interoperation layer. 11 EVM: Ethereum Virtual Machine (https://github.com/ethereum/ethereumj)

TVM workflow showing compiler translating Solidity smart contracts into bytecode for execution on the TRON Virtual Machine

Figure 3: TVM Workflow

6.3 Performance 6.3.1 Lightweight Architecture

TVM adopts a lightweight architecture with the aim of reducing resource consumption to guarantee system performance. 6.3.2 Robust

TRX transfers and smart contract execution cost bandwidth points only, instead of TRX, which exempts TRON from being attacked. Bandwidth consumption is predictable and static since each computational step cost is fixed. 6.3.3 High Compatibility

TVM is compatible with EVM and will be compatible with more mainstream VMs in the future. Thereby, all smart contracts on EVM are executable on TVM. 6.3.4 Low Cost

Due to TVM’s bandwidth setup, development costs are reduced and developers can focus on the logic development of their contract code. TVM also offers all-in-one interfaces for contract deployment, triggering and viewing to offer the convenience for developers.

TRON 虚拟机

6.1 简介

TRON 虚拟机(TVM)是一个轻量级的、图灵完备的虚拟机,为 TRON 的生态系统。其目标是提供一个高效、定制的 blockchain 系统。 方便、稳定、安全、可扩展。

TVM 最初从 EVM 分叉出来,可以与现有的 Solidity smart contract 无缝连接 11 发展生态系统。基于此,TVM还支持DPoS共识。

TVM 采用能量的概念。与 EVM 上的 Gas 机制不同, TVM 上的交易和 smart contract 是免费的,不消耗 TRX。技术上可行 TVM的计算能力不受tokens总持有量的限制。 6.2 工作流程

编译器首先将 Solidity smart contract 转换为可读且可执行的字节码 TVM。然后TVM通过opcode处理数据,相当于操作逻辑 基于堆栈的有限状态机。最后,TVM 访问 blockchain 数据并调用 通过互操作层的外部数据接口。 11 EVM: Ethereum 虚拟机 (https://github.com/ethereum/ethereumj)

TVM workflow showing compiler translating Solidity smart contracts into bytecode for execution on the TRON Virtual Machine

图 3:TVM 工作流程

6.3 性能 6.3.1 轻量级架构

TVM采用轻量级架构,旨在减少资源消耗,保证 系统性能。 6.3.2 稳健

TRX 传输和 smart contract 执行仅消耗带宽点,而不是 TRX,这 使 TRON 免受攻击。带宽消耗是可预测的并且是静态的,因为每个 计算步骤成本是固定的。 6.3.3 高兼容性

TVM兼容EVM,未来将兼容更多主流VM。 因此,EVM 上的所有 smart contract 都可以在 TVM 上执行。 6.3.4 低成本

由于TVM的带宽设置,降低了开发成本,开发人员可以专注于 他们的合约代码的逻辑开发。 TVM 还为合约提供一体化接口 部署、触发、查看,为开发者提供便利。

Smart Contract

Smart Contract

7.1 Introduction

A smart contract is a protocol that digitally verifies contract negotiation. They define the rules and penalties related to an agreement and also automatically enforce those obligations. The smart contract code facilitates, verifies, and enforces the negotiation or performance of an agreement or transaction. From a tokenization perspective, smart contracts also facilitate automatic funds transfers between participating parties should certain criteria be met.

TRON smart contracts are written in the Solidity language. Once written and tested, they can be compiled into bytecode, then deployed onto the TRON network for the TRON Virtual Machine. Once deployed, smart contracts can be queried via their contract addresses. The contract Application Binary Interface (ABI) shows the contract’s call functions and is used for interacting with the network. 7.2 Energy Model

The maximum energy limit for deploying and triggering a smart contract is a function of several variables:

● Dynamic energy from freezing 1 TRX is 50,000,000,000 (Total Energy Limit) / (Total Energy Weight) ● Energy limit is the daily account energy limit from freezing TRX ● Remaining daily account energy from freezing TRX is calculated as Energy Limit - Energy Used ● Fee limit in TRX is set in smart contract deploy/trigger call ● Remaining usable TRX in the account ● Energy per TRX if purchased directly (10 SUN = 1 Energy) = 100,000, SRs can vote on adjustment

There are two consumption scenarios to calculate for maximum energy limit for deployment and trigger. The logic can be expressed as follows:
const​ R = Dynamic Energy Limit const​ F = Daily account energy ​from​ freezing TRX const​ E = Remaining daily account energy ​from​ freezing TRX const​ L = Fee limit ​in​ TRX set ​in​ deploy/trigger call const​ T = Remaining usable TRX ​in​ account

const​ C = Energy per TRX ​if​ purchased directly

// Calculate M, defined as maximum energy limit for deployment/trigger of smart contract if​ F > LR let​ M = min(E+TC, LR) else let​ M = E+TC 7.3 Deployment

When a TRON solidity smart contract is compiled, the TRON Virtual Machine reads the compiled bytecode. The bytecode consists of a section for code deployment, contract code, and the Auxdata. The Auxdata is the source code’s cryptographic fingerprint, used for verification. The deployment bytecode runs the constructor function and sets up the initial storage variables. The deployment code also calculates the contract code and returns it to the TVM. The ABI is a JSON file that describes a TRON smart contract’s functions. This file defines the function names, their payability, the function return values, and their state mutability. 7.4 Trigger Function

Once the TRON smart contracts are deployed, their functions can be triggered individually either via TronStudio or through API calls. State-changing functions require Energy while read-only functions execute without Energy. 7.5 TRON Solidity

TRON Solidity is a fork from Ethereum’s Solidity language. TRON modifies the original project to support TRX and SUN units (1 TRX = 1,000,000 SUN). The rest of the language syntax is compatible with Solidity ^0.4.24. Thus the Tron Virtual Machine (TVM) is almost 100% compatible with EVM instructions.

智能合约

7.1 简介

smart contract 是一种以数字方式验证合同协商的协议。他们定义规则并 与协议相关的处罚,并自动执行这些义务。聪明的 合同代码促进、验证和强制执行协议或协议的谈判或履行 交易。从 token 化的角度来看,smart contract 也有利于自动资金 参与方之间的转移应满足某些标准。

TRON smart contract 是用 Solidity 语言编写的。一旦编写并测试,它们就可以 编译为字节码,然后部署到 TRON 虚拟机的 TRON 网络上。曾经 部署后,可以通过合约地址查询smart contract。合同申请 二进制接口(ABI)显示了合约的调用函数,用于与合约进行交互 网络。 7.2 能量模型

部署和触发 smart contract 的最大能量限制是几个函数的函数 变量:

● 冻结1 TRX的动态能量为50,000,000,000(总能量限制)/(总能量 重量) ● 能量限额是账户每天冻结TRX的能量限额 ● 每日账户冻结TRX剩余能量计算为Energy Limit - Energy 二手 ● TRX 的费用限制在 smart contract 部署/触发调用中设置 ● 账户剩余可用TRX ● 如果直接购买,每个 TRX 的能量(10 SUN = 1 能量)= 100,000,SR 可以投票 调整

有两种消耗场景可以计算部署的最大能量限制和 触发。逻辑可以表达如下:
const​ R = Dynamic Energy Limit const​ F = Daily account energy ​from​ freezing TRX const​ E = Remaining daily account energy ​from​ freezing TRX const​ L = Fee limit ​in​ TRX set ​in​ deploy/trigger call const​ T = Remaining usable TRX ​in​ account

const​ C = Energy per TRX ​if​ purchased directly

// Calculate M, defined as maximum energy limit for deployment/trigger of smart contract if​ F > LR let​ M = min(E+TC, LR) else let​ M = E+TC 7.3 部署

当编译 TRON Solidity smart contract 时,TRON 虚拟机读取已编译的 字节码。字节码由代码部署、合约代码和辅助数据部分组成。 Auxdata 是源代码的加密指纹,用于验证。部署情况 字节码运行构造函数并设置初始存储变量。部署情况 code 还计算合约代码并将其返回给 TVM。 ABI 是一个 JSON 文件, 描述 TRON smart contract 的功能。该文件定义了函数名称、它们的可支付性、 函数返回值及其状态可变性。 7.4 触发功能

一旦部署了 TRON smart contract,它们的功能就可以通过以下方式单独触发: TronStudio 或通过 API 调用。状态改变功能需要能量,而只读功能 无需能量即可执行。 7.5 TRON 坚固性

TRON Solidity 是 Ethereum Solidity 语言的分支。 TRON 将原项目修改为 支持TRX和SUN单位(1 TRX = 1,000,000 SUN)。其余的语言语法是 与 Solidity ^0.4.24 兼容。因此 Tron 虚拟机 (TVM) 几乎 100% 兼容 带有 EVM 指令。

Token

Token

8.1 TRC-10 Token

In the TRON network, each account can issue tokens at the expense of 1024 TRX. ​To issue tokens, the issuer needs to specify a token name, the total capitalization, the exchange rate to TRX, circulation duration, description, website, maximum bandwidth consumption per account, total bandwidth consumption, and the amount of token frozen. Each token issuance can also configure each account’s maximum daily token transfer Bandwidth Points, the entire network’s maximum daily token transfer Bandwidth Points, total token supply, locking duration in days, and the total amount of tokens locked. 8.2 TRC-20 Token

TRC-20 is a technical standard used for smart contracts implementing tokens supported by the TRON Virtual Machine. It is fully compatible with ERC-20.

The interface is as follows:
contract​ TRC20Interface { ​function​ ​totalSupply​() ​public​ ​constant​ ​returns​ (uint); ​function​ ​balanceOf​(address tokenOwner) ​public​ ​constant​ ​returns​ (uint balance); ​function​ ​allowance​(address tokenOwner, address spender) ​public​ ​constant returns​ (uint remaining); ​function​ ​transfer​(address to, uint tokens) ​public​ ​returns​ (bool success); ​function​ ​approve​(address spender, uint tokens) ​public​ ​returns​ (bool success); ​function​ ​transferFrom​(address from, address to, uint tokens) ​public returns​ (bool success);

​event​ ​Transfer​(address indexed from, address indexed to, uint tokens); 
​event​ ​Approval​(address indexed tokenOwner, address indexed spender, uint

tokens); }

From a developer’s perspective, there are several differences between TRC-10 and TRC-20. Some of the key differences are that TRC-10 tokens are accessible by APIs and smart contracts while TRC-20 tokens allow for interface customization but are only accessible within smart contracts.

From a cost perspective, TRC-10 tokens have transaction fees that are 1000 times lower than TRC-20, but carry bandwidth costs for API transfers and deposits. Transfers and deposits in smart contracts for TRC-10 tokens cost both bandwidth and energy.
8.3 Beyond

Since TRON uses the same Solidity version as Ethereum, more token standards could be readily ported to TRON.

代币

8.1 TRC-10 代币

在TRON网络中,每个账户可以发行tokens,费用为1024 TRX。​要发行 tokens, 发行人需要指定token名称、总资本、与TRX的汇率、 流通时长、描述、网站、每个账户最大带宽消耗、总计 带宽消耗和 token 冻结量。每个token发行还可以配置 每个账户每日最大token转账带宽点,全网每日最大 token 转移带宽积分、token 供应总量、锁定时长(天)以及总量 token 已锁定。 8.2 TRC-20 代币

TRC-20 是用于 smart contracts 实现 tokens 的技术标准,由 TRON 虚拟机。它与ERC-20完全兼容。

界面如下:
合约TRC20接口{ ​函数​ ​totalSupply​() ​公共​ ​常量​ ​返回​ (uint); ​函数​ ​balanceOf​(地址tokenOwner)​公共​ ​常量​ ​返回​(uint 平衡); ​功能​ ​津贴​(地址token所有者,地址支出者)​公共​ ​常量 返回(剩余 uint); ​函数​ ​传输​(地址,uint tokens)​public​ ​返回​(布尔成功); ​函数​ ​批准​(地址支出者,uint tokens)​公共​ ​返回​(bool 成功); ​函数​ ​transferFrom​(地址来自,地址至,uint tokens)​公共 返回(布尔成功);

​事件​ ​传输​(索引地址,索引地址,uint tokens); 
​事件​ ​批准​(地址索引 tokenOwner,地址索引支出者,uint

tokens); }

从开发人员的角度来看,TRC-10 和 TRC-20 之间存在一些差异。一些 主要区别在于 TRC-10 token 可以通过 API 和 smart contract 访问,而 TRC-20 tokens 允许界面定制,但只能在 smart contracts 内访问。

从成本角度来看,TRC-10 token 的交易费用比 TRC-20,但会承担 API 传输和存款的带宽成本。智能转账和存款 TRC-10 token 的合约会消耗带宽和能源。
8.3 超越

由于 TRON 使用与 Ethereum 相同的 Solidity 版本,因此可以轻松创建更多 token 标准 移植到 TRON。

Governance

Governance

9.1 Super Representative 9.1.1 General

Every account in the TRON network can apply and have the opportunity to become a Super Representative (denoted as SR). Everyone can vote for SR candidates. The top 27 candidates with the most votes will become SRs with the right and obligation to generate blocks. The votes are counted every 6 hours and the SRs will change accordingly.

To prevent malicious attacks, there is a cost to becoming an SR candidate. When applying, 9999 TRX will be burned from the applicant’s account. Once successful, such account can join the SR election. 9.1.2 Election

TRON Power (denoted as TP) is needed to vote and the amount of TP depends on the voter’s frozen assets (TRX).

TP is calculated in the following way:
TP 1 TRX frozen to get bandwidth 1 =

Every account in the TRON network has the right to vote for their own SRs.

After the release (unfreeze, available after 3 days), users won't have any frozen assets and lose all TP accordingly. As a result, all votes become invalid for the ongoing and future voting round unless TRX is frozen again to vote.

Note that the TRON network only records the most recent vote, which means that every new vote will negate all previous votes. 9.1.3 Reward a. Vote Reward

Also known as Candidate Reward, which the top 127 candidates updated once every round (6 hours) will share 115,200 TRX as mined. The reward will be split in accordance with the vote weight each candidate receives. Each year, the total reward for candidates will be 168,192,000 TRX. Total vote reward per round Why 115,200 TRX every round? 15, 00 TRX total vote reward per round (V R/round) 1 2 =
V R/round = 16 T RX/block × 20 blocks/min × 60 mins/hr × 6 hrs/round Notice: this is set by WITNESS_STANDBY_ALLOWANCE = 115,200 TRX. See dynamic network parameters. Total vote reward per year Why 168,192,000 TRX every year? 168, 192, 000 T RX = total vote reward per year (V R/year) V R/year = 115, 200 T RX/round × 4 rounds/day × 365 days/year b. Block Reward Also known as Super Representative Reward, which the top 27 candidates (SRs) who are elected every round (6 hours) will share roughly 230,400 TRX as mined. The reward will be split evenly between the 27 SRs (minus the total reward blocks missed due to network error). A total of 336,384,000 TRX will be awarded annually to the 27 SRs. Total block reward per round Why 230,400 TRX every round? 230, 400 T RX = total block reward per round (BR/round) BR/round = 32 T RX/bloc × 20 blocks/min × 60 mins/hr × 6 hrs/round Notice: the unit block reward is set by WITNESS_PAY_PER_BLOCK = 32 TRX. See dynamic network parameters. Total block reward per year Why 336,384,000 TRX every year? 336, 384, 000 T RX = total block reward per year (BR/year) BR/year = 230, 400 T RX/round × 4 rounds/day × 365 days/year January 1, 2021 There will be no inflation on the TRON network before January 1, 2021, and the TRON DAO will award all block rewards and candidate rewards prior to that date. c. Reward Calculation

SR reward calculation otal reward vote reward (V R) block reward (BR) t =
+

R total V R V =
×
total votes votes SR candidate received
R

block missed 2 B =
27 total BR − × 3
Note: the reward is calculated per SR per round (6 hours)

Rank 28 to rank 127 SR candidate reward calculation otal reward vote reward (V R) t =

R total V R V =
×
total votes votes SR candidate received
Note: the reward is calculated per SR candidate per round (6 hours) 9.2 Committee 9.2.1 General

The committee is used to modify TRON dynamic network parameters, such as block generation rewards, transaction fees, etc. The committee consists of the 27 SRs in the current round. Each SR has the right to propose and vote on proposals. When a proposal receives 19 votes or more, it is approved and the new network parameters will be applied in the next maintenance period (3 days). 9.2.2 Dynamic Network Parameters 0. MAINTENANCE_TIME_INTERVAL a. Description
Modify the maintenance interval time in ms. Known as the SR vote interval time per round.
b. Example [6 * 3600 * 1000] ms - which is 6 hours. c. Range [3 * 27* 1000, 24 * 3600 * 1000] ms 1. ACCOUNT_UPGRADE_COST a. Description Modify the cost of applying for SR account. b. Example [9,999,000,000] SUN - which is 9,999 TRX. c. Range [0,100 000 000 000 000 000] SUN 2. CREATE_ACCOUNT_FEE a. Description Modify the account creation fee.

b. Example [100,000] SUN - which is 1 TRX. c. Range [0,100 000 000 000 000 000] SUN 3. TRANSACTION_FEE a. Description Modify the amount of fee used to gain extra bandwidth. b. Example [10] SUN/byte. c. Range [0,100 000 000 000 000 000] SUN/byte 4. ASSET_ISSUE_FEE a. Description Modify asset issuance fee. b. Example [1024,000,000] SUN - which is 1024 TRX. c. Range [0,100 000 000 000 000 000] SUN 5. WITNESS_PAY_PER_BLOCK a. Description Modify SR block generation reward. Known as unit block reward. b. Example [32,000,000] SUN - which is 32 TRX. c. Range [0,100 000 000 000 000 000] SUN 6. WITNESS_STANDBY_ALLOWANCE a. Description Modify the rewards given to the top 127 SR candidates. Known as total vote reward per round. b. Example [115,200,000,000] SUN - which is 115,200 TRX. c. Range [0,100 000 000 000 000 000] SUN 7. CREATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT a. Description Modify the cost of account creation. Combine dynamic network parameters #8 to get total account creation cost:
REATE_NEW_ACCOUNT_FEE_IN_SY STEM_CONTRACT REATE_NEW_ACCOUNT_BANDWIDTH_RATE
C × C

b. Example [0] SUN. c. Range [0,100 000 000 000 000 000] SUN 8. CREATE_NEW_ACCOUNT_BANDWIDTH_RATE

a. Description Modify the cost of account creation. Combine dynamic network parameters #7 to get total account creation cost:
REATE_NEW_ACCOUNT_FEE_IN_SY STEM_CONTRACT REATE_NEW_ACCOUNT_BANDWIDTH_RATE
C × C

b. Example [1]. c. Range [0,100,000,000,000,000,000] 9. ALLOW_CREATION_OF_CONTRACTS a. Description To turn on Tron Virtual Machine (TVM). b. Example True - set to activate and effect since 10/10/2018 23:47 UTC. c. Range True/False 10. REMOVE_THE_POWER_OF_THE_GR a. Description Remove the initial GR genesis votes b. Example True - effected at 11/4/2018 08:46 UTC. c. Range True/False - Notice: cannot set back to False from True. 11. ENERGY_FEE a. Description Modify the fee of 1 energy. b. Example 20 SUN. c. Range [0,100 000 000 000 000 000] SUN 12. EXCHANGE_CREATE_FEE a. Description Modify the cost of trading pair creation. Known as the cost of creating a trade order. b. Example [1,024,000,000] SUN - which is 1024 TRX. c. Range [0,100 000 000 000 000 000] SUN 13. MAX_CPU_TIME_OF_ONE_TX a. Description Modify the maximum execution time of one transaction. Known as the timeout limit of one transaction. b. Example 50 ms. c. Range

[0, 1000] ms 14. ALLOW_UPDATE_ACCOUNT_NAME a. Description Modify the option to let an account update their account name.
b. Example False - which is available to propose from java-tron Odyssey v3.2. c. Range True/False - Notice: cannot set back to False from True. 15. ALLOW_SAME_TOKEN_NAME a. Description Modify the validation of allowing different token have a duplicate name.
b. Example False - which is available to propose from java-tron Odyssey v3.2. c. Range True/False - Notice: cannot set back to False from True. 16. ALLOW_DELEGATE_RESOURCE a. Description Modify the validation of allowing to issue token with a duplicate name, so the tokenID​ of the token, in long integer data type, would be the only atomic identification of a token.
b. Example False - which is available to propose from java-tron Odyssey v3.2. c. Range True/False - Notice: cannot set back to False from True. 17. TOTAL_ENERGY_LIMIT a. Description Modify the whole network total energy limit. b. Example [50,000,000,000,000,000] SUN - which is 50,000,000,000 TRX. c. Range [0,100,000,000,000,000,000] SUN 18. ALLOW_TVM_TRANSFER_TRC10 a. Description Allow TRC-10 token transfer within smart contracts. ALLOW_UPDATE_ACCOUNT_NAME, ALLOW_SAME_TOKEN_NAME, ALLOW_DELEGATE_RESOURCE proposals must all be approved before proposing this parameter change.
b. Example False - which is available to propose from java-tron Odyssey v3.2. c. Range True/False - Notice: cannot set back to False from True.

9.2.3 Create Proposal

Only the SR accounts have the rights to propose a change in dynamic network parameters. 9.2.4 Vote Proposal

Only committee members (SRs) can vote for a proposal and the member who does not vote in time will be considered as a disagree. The proposal is active for 3 days after it is created. The vote can be changed or retrieved during the 3-days voting window. Once the period ends, the proposal will either succeed (19+ votes) or fail (and end). 9.2.5 Cancel Proposal

The proposer can cancel the proposal before it becomes effective. 9.3 Structure

SRs are the witnesses of newly generated blocks. A witness contains 8 parameters:
1. address​: the address of this witness – e.g. 0xu82h…7237.
2. voteCount​: number of received votes on this witness – e.g. 234234.
3. pubKey​: the public key for this witness – e.g. 0xu82h…7237.
4. url​: the url for this witness – e.g. https://www.noonetrust.com.
5. totalProduced​: the number of blocks this witness produced – e.g. 2434.
6. totalMissed​: the number of blocks this witness missed – e.g. 7.
7. latestBlockNum​: the latest height of block – e.g. 4522. 8. isjobs​: a boolean flag.

Protobuf data structure: message​ ​Witness​{
​bytes​ address = ​1​;
​int64​ voteCount = ​2​;
​bytes​ pubKey = ​3​;
​string​ url = ​4​;
​int64​ totalProduced = ​5​;
​int64​ totalMissed = ​6​;
​int64​ latestBlockNum = ​7​; ​bool​ isJobs = ​8​; }

  1. DApp Development 10.1 APIs

The TRON network offers a wide selection of over 60+ HTTP API gateways for interacting with the network via Full and Solidity Nodes. Additionally, TronWeb is a comprehensive JavaScript library containing API functions that enable developers to deploy smart contracts, change the blockchain state, query blockchain and contract information, trade on the DEX, and much more. These API gateways can be directed towards a local privatenet, the Shasta testnet, or the TRON Mainnet.

10.2 Networks

TRON has both a Shasta testnet as well as a Mainnet. Developers may connect to the networks by deploying nodes, interacting via TronStudio, or using APIs via the TronGrid service. The TronGrid service consists of load balanced node clusters hosted on AWS servers worldwide. As DApp development scales up and API call volumes increase, TronGrid successfully fields the increase in API traffic.
10.3 Tools

TRON offers a suite of development tools for enabling developers to create innovative DApps.
TronBox is a framework that allows developers to test and deploy smart contracts via the TronWeb API. TronGrid is a load balanced and hosted API service that allows developers to access the TRON network without having to run their own node. TronGrid offers access to both the Shasta testnet as well as the TRON Mainnet. TronStudio is a comprehensive Integrated Development Environment (IDE) that enables developers to compile, deploy, and debug their Solidity smart contracts. TronStudio contains an internal full node that creates a private local environment for smart contract testing prior to deployment. The TronWeb API library connects developers to the network via a wide selection of HTTP API calls wrapped in JavaScript.
10.4 Resources

The TRON Developer Hub is a comprehensive API documentation site tailored towards 12 developers wishing to build on the TRON network. The Developer Hub provides a high-level conceptual understanding of TRON and walks users through the details of interacting with the 12 Developer Hub: https://developers.tron.network/

network. The guides walk developers through node setup, deployment and interaction with smart contracts, API interaction and implementation, building sample DApps, and using each of the developer tools. Additionally, developer community channels are available through Discord .
13

13 Discord: https://discordapp.com/invite/GsRgsTD

  1. Conclusion

TRON is a scalable blockchain solution that has employed innovative methods for tackling challenges faced by legacy blockchain networks. Having reached over 2M transactions per day, with over 700K TRX accounts, and surpassing 2000 TPS, TRON has enabled the community in creating a decentralized and democratized network.

治理

9.1 超级代表 9.1.1 概述

TRON 网络中的每个帐户都可以申请并有机会成为超级会员 代表(记为SR)。每个人都可以投票给 SR 候选人。前 27 名候选人 得票最多的将成为具有生成区块权利和义务的SR。票数为 每 6 小时计算一次,SR 会相应变化。

为了防止恶意攻击,成为 SR 候选者需要付出一定的成本。申请时,9999 TRX将从申请人的账户中销毁。成功后,该账户即可加入SR 选举。 9.1.2 选举

TRON 投票需要Power(记为TP),TP的数量取决于投票者的投票权 冻结资产(TRX)。

TP的计算方法如下:
TP 冻结 1 TRX 以获得带宽 1 =

TRON 网络中的每个帐户都有权为自己的 SR 投票。

发布后(解冻,3天后可用),用户不会有任何冻结的资产,并失去所有 相应地TP。因此,所有投票对于当前和未来的投票轮均无效,除非 TRX再次被冻结投票。

请注意,TRON 网络仅记录最近的投票,这意味着每一次新投票 将否定之前所有的投票。 9.1.3 奖励 a.投票奖励

也称为候选人奖励,前 127 名候选人每轮更新一次(6 小时)将分享开采的 115,200 TRX。奖励将按照投票权重进行瓜分 每位候选人都会收到。每年,候选人的总奖励为168,192,000 TRX。 每轮总投票奖励 为什么每轮 115,200 TRX? 15, 00 TRX 每轮总投票奖励(V R/轮) 1 2 =
VR/轮 = 16 T RX/块 × 20 块/分钟 × 60 分钟/小时 × 6 小时/轮 注意:这是由 WITNESS_STANDBY_ALLOWANCE = 115,200 TRX 设置的。请参阅动态网络参数。 每年总投票奖励 为什么每年168,192,000 TRX? 168, 192, 000 T RX = 每年总投票奖励(VR/年) VR/年 = 115, 200 T RX/轮 × 4 轮/天 × 365 天/年 b.区块奖励 也称为超级代表奖励,当选的前27名候选人(SR) 每轮(6小时)将分享大约230,400个已开采的TRX。奖励将平分 27 个 SR 之间(减去由于网络错误而错过的总奖励块)。总共有 每年将向 27 名 SR 奖励 336,384,000 TRX。 每轮总区块奖励 为什么每轮 230,400 TRX? 230, 400 T RX = 每轮总区块奖励(BR/轮) BR/轮 = 32 T RX/块 × 20 块/分钟 × 60 分钟/小时 × 6 小时/轮 注意:单位区块奖励由 WITNESS_PAY_PER_BLOCK = 32 TRX 设置。查看动态网络 参数。 每年的总区块奖励 为什么每年有 336,384,000 TRX? 336, 384, 000 T RX = 每年总区块奖励(BR/年) BR/年 = 230, 400 T RX/轮 × 4 轮/天 × 365 天/年 2021 年 1 月 1 日 2021 年 1 月 1 日之前 TRON 网络不会出现通货膨胀,TRON DAO 将 在此日期之前授予所有区块奖励和候选人奖励。 c.奖励计算

SR奖励计算 总奖励 投票奖励(VR) 区块奖励(BR) t =
+

右 总VR V =
×
总票数 SR 候选人收到的票数

块错过了 2 乙 =
27 号 总BR - × 3
注:奖励按每轮(6小时)SR计算

排名28~排名127 SR候选人奖励计算 总奖励 投票奖励(VR) t =

右 总VR V =
×
总票数 SR 候选人收到的票数
注:奖励按每个SR候选人每轮(6小时)计算 9.2 委员会 9.2.1 概述

该委员会用于修改TRON动态网络参数,例如区块生成 奖励、交易费用等。委员会由本轮27名SR组成。每个SR 拥有提案权和对提案的表决权。当一项提案获得 19 票或以上时, 批准后,新的网络参数将在下一个维护周期(3天)内应用。 9.2.2 动态网络参数 0。 MAINTENANCE_TIME_INTERVAL a. 描述
修改维护间隔时间(以毫秒为单位)。称为 SR 投票间隔时间 圆形。
b. 示例 [6 * 3600 * 1000] 毫秒 - 即 6 小时。 c. 范围 [3271000, 2436001000] 毫秒 1. ACCOUNT_UPGRADE_COST a. 描述 修改申请SR账户的费用。 b. 示例 [9,999,000,000] SUN - 即 9,999 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 2. CREATE_ACCOUNT_FEE a. 描述 修改账户创建费用。b. 示例 [100,000] SUN - 1 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 3. 交易费 a. 描述 修改用于获得额外带宽的费用金额。 b. 示例 [10] 太阳/字节。 c. 范围 [0,100 000 000 000 000 000] SUN/字节 4. ASSET_ISSUE_FEE a. 描述 修改资产发行费用。 b. 示例 [1024,000,000] SUN - 即 1024 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 5. WITNESS_PAY_PER_BLOCK a. 描述 修改SR区块生成奖励。称为单位区块奖励。 b. 示例 [32,000,000] SUN - 即 32 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 6. WITNESS_STANDBY_ALLOWANCE a. 描述 修改前127名SR候选人的奖励。称为总投票奖励 每轮。 b. 示例 [115,200,000,000] SUN - 115,200 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 7. CREATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT a. 描述 修改帐户创建成本。结合动态网络参数#8得到 帐户创建总成本:
REATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT REATE_NEW_ACCOUNT_BANDWIDTH_RATE
C × C

b. 示例 [0] 周日。 c. 范围 [0,100 000 000 000 000 000] 太阳 8. CREATE_NEW_ACCOUNT_BANDWIDTH_RATE

a. 描述 修改帐户创建成本。结合动态网络参数#7得到 帐户创建总成本:
REATE_NEW_ACCOUNT_FEE_IN_SYSTEM_CONTRACT REATE_NEW_ACCOUNT_BANDWIDTH_RATE
C × C

b. 示例 [1]。 c. 范围 [0,100,000,000,000,000,000] 9. 允许创建合同 a. 描述 打开 Tron 虚拟机 (TVM)。 b. 示例 True - 设置为自 10/10/2018 23:47 UTC 起激活并生效。 c. 范围 对/错 10. 删除_THE_POWER_OF_THE_GR a. 描述 删除最初的 GR 创世投票 b. 示例 正确 - 于 11/4/2018 08:46 UTC 生效。 c. 范围 True/False - 注意:不能从 True 设置回 False。 11.能源费 a. 描述 修改1能量的费用。 b. 示例 20 日。 c. 范围 [0,100 000 000 000 000 000] 太阳 12. EXCHANGE_CREATE_FEE a. 描述 修改交易对创建成本。称为创建贸易订单的成本。 b. 示例 [1,024,000,000] SUN - 即 1024 TRX。 c. 范围 [0,100 000 000 000 000 000] 太阳 13. MAX_CPU_TIME_OF_ONE_TX a. 描述 修改一笔交易的最大执行时间。称为超时限制 一笔交易。 b. 示例 50 毫秒 c. 范围

[0, 1000] 毫秒 14.ALLOW_UPDATE_ACCOUNT_NAME a. 描述 修改选项以让帐户更新其帐户名。
b. 示例 False - 可从 java-tron Odyssey v3.2 中提出。 c. 范围 True/False - 注意:不能从 True 设置回 False。 15.ALLOW_SAME_TOKEN_NAME a. 描述 修改允许不同token有重复名称的验证。
b. 示例 False - 可从 java-tron Odyssey v3.2 中提出。 c. 范围 True/False - 注意:不能从 True 设置回 False。 16. ALLOW_DELEGATE_RESOURCE a. 描述 修改允许签发 token 重名的验证,这样 token 的 tokenID​,在长整数数据类型中,将是唯一的原子 token 的标识。
b. 示例 False - 可从 java-tron Odyssey v3.2 中提出。 c. 范围 True/False - 注意:不能从 True 设置回 False。 17. TOTAL_ENERGY_LIMIT a. 描述 修改全网总能量限制。 b. 示例 [50,000,000,000,000,000] SUN - 即 50,000,000,000 TRX。 c. 范围 [0,100,000,000,000,000,000] 太阳 18. ALLOW_TVM_TRANSFER_TRC10 a. 描述 允许在 smart contract 秒内传输 TRC-10 token。 ALLOW_UPDATE_ACCOUNT_NAME、ALLOW_SAME_TOKEN_NAME、 ALLOW_DELEGATE_RESOURCE 提案必须在提案前全部获得批准 这个参数改变。
b. 示例 False - 可从 java-tron Odyssey v3.2 中提出。 c. 范围 True/False - 注意:不能从 True 设置回 False。9.2.3 创建提案

只有 SR 账户才有权提议更改动态网络参数。 9.2.4 投票提案

只有委员会成员 (SR) 才能对提案进行投票,未及时投票的成员 将被视为不同意。提案创建后 3 天内有效。投票可以 在 3 天的投票窗口内可以更改或检索。期限结束后,该提案将 要么成功(19票以上),要么失败(结束)。 9.2.5 取消提案

提案人可以在提案生效前取消提案。 9.3 结构

SR 是新生成区块的见证人。见证人包含8个参数:
1. 地址​:该证人的地址 – 例如0xu82h…7237。
2. voteCount​:收到的对该见证人的投票数 – 例如234234。
3. pubKey​:该见证人的公钥 - 例如0xu82h…7237。
4. url​:该证人的 url – 例如https://www.noonetrust.com.
5. TotalProduced​:该见证人生成的区块数量 – 例如2434.
6. TotalMissed​:该见证人错过的区块数量 – 例如7.
7. latestBlockNum​:区块的最新高度 – 例如4522. 8. isjobs​:布尔标志。

Protobuf数据结构: 留言​​见证​{
​字节​地址 = ​1​;
​int64​ voteCount = ​2​;
​字节​ pubKey = ​3​;
​字符串​ url = ​4​;
​int64​ 总生产量 = ​5​;
​int64​ 总丢失数 = ​6​;
​int64​latestBlockNum = ​7​; ​布尔​ isJobs = ​8​; }

10.DApp开发 10.1 API

TRON 网络提供了 60 多个 HTTP API 网关的广泛选择,用于与 通过完整节点和 Solidity 节点的网络。此外,TronWeb 是一个综合性的 JavaScript 库 包含使开发人员能够部署 smart contracts 的 API 函数,更改 blockchain 状态、查询 blockchain 和合约信息、在 DEX 上进行交易等等。这些API 网关可以定向到本地私有网、Shasta 测试网或 TRON 主网。

10.2 网络

TRON 既有 Shasta 测试网又有主网。开发人员可以通过以下方式连接到网络 部署节点、通过 TronStudio 交互或通过 TronGrid 服务使用 API。特隆网格 服务由托管在全球 AWS 服务器上的负载均衡节点集群组成。作为DApp 开发规模扩大,API 调用量增加,TronGrid 成功应对了 API 流量。
10.3 工具

TRON 提供了一套开发工具,使开发人员能够创建创新的 DApp。
TronBox 是一个允许开发人员通过 TronWeb 测试和部署 smart contracts 的框架 API。 TronGrid 是一个负载平衡和托管的 API 服务,允许开发人员访问 TRON 网络无需运行自己的节点。 TronGrid 提供对 Shasta 的访问 测试网以及 TRON 主网。 TronStudio是一个综合性的集成开发 使开发人员能够编译、部署和调试 Solidity smart 的环境 (IDE) 合同。 TronStudio 包含一个内部完整节点,可创建私有本地环境 smart contract 在部署之前进行测试。 TronWeb API 库将开发人员连接到 网络通过封装在 JavaScript 中的多种 HTTP API 调用进行选择。
10.4 资源

TRON 开发人员中心是一个综合性 API 文档网站,专为 12 希望在 TRON 网络上进行开发的开发人员。开发者中心提供了高水平的 TRON 的概念性理解,并引导用户完成与 TRON 交互的细节 12 开发者中心:https://developers.tron.network/

网络。该指南引导开发人员完成节点设置、部署以及与智能交互 合约、API 交互和实现、构建示例 DApp 以及使用每个 开发者工具。此外,还可以通过 Discord 获得开发者社区渠道。
13

13 不和谐:https://discordapp.com/invite/GsRgsTD

  1. 结论

TRON 是一个可扩展的 blockchain 解决方案,采用创新方法来解决 传统 blockchain 网络面临的挑战。每日交易量已超过 200 万笔, 拥有超过 70 万个 TRX 账户,超过 2000 个 TPS、TRON 使社区能够 创建一个去中心化和民主化的网络。