Tron-IDE
智能合约在线编辑器
概述
Tron-IDE是一款帮助TRON网络开发者开发智能合约的在线编辑器。它具有模块化的特点,以插件的方式为开发者提供智能合约的编辑、编译、部署等功能。
你将学到什么?
通过本章学习,您将学会如何通过Tron-IDE编译、部署合约至TRON网络。
你将做什么?
- 在TRON-IDE上创建文件
- 编译合约
- 部署智能合约
TRON-IDE入门
TRON-IDE是一个专注于TRON网络开发智能合约的在线IDE, 你可以通过这个链接进行访问。
TronLink插件安装
TRON-IDE需要通过TronLink钱包与账户、节点进行数据交互,TronLink安装及操作如下:
- 安装TronLink Chrome插件
- 通过创建账户、导入账户、链接硬件钱包 三种方式创建账户
- 测试网可以通过水龙头获取测试代币
- TronLink插件上选择对应的网络
编写HelloWorld合约
要开始构建智能合约,请单击新建文件并将其命名为 HelloWorld.sol:
现在将下面的代码复制并粘贴到新创建的HelloWorld.sol文件中:
// Specifies that the source code is for a version
// of Solidity greater than 0.5.10
pragma solidity ^0.5.10;
// A contract is a collection of functions and data (its state)
// that resides at a specific address on the Ethereum blockchain.
contract HelloWorld {
// The keyword "public" makes variables accessible from outside a contract
// and creates a function that other contracts or SDKs can call to access the value
string public message;
// A special function only run during the creation of the contract
constructor(string memory initMessage) public {
// Takes a string value and stores the value in the memory data storage area,
// setting `message` to that value
message = initMessage;
}
// A publicly accessible function that takes a string as a parameter
// and updates `message`
function update(string memory newMessage) public {
message = newMessage;
}
}编译合约
使用SOLIDITY编译器插件(Solidity compiler),选择相应的版本,对编写好的智能合约进行编译,编译成功后会返回编译结果信息,包括ABI,Bytecode等;编译失败,左下方会返回红色的具体信息。
现在,我们编译上述HelloWorld合约,其中编译版本选择0.5.16:
部署合约
编译成功后,使用部署插件(DEPLOYMENT), 我们将编译好的HelloWorld合约部署至TRON Shasta测试网:
一旦TronLink连接到TRON-IDE,点击“部署”按钮,则TronLink将弹出创建智能合约的签名窗口,确认签名。
部署成功后终端会返回交易信息。

到此您已成功部署HelloWorld合约,现在您可以根据合约地址在Shasta测试网检查部署状态,并且与部署的合约进行交互。
Updated 9 months ago