创建和编译
本节将介绍 Hello World 合约的创建和编译。 这是用 Solidity 编写的合约。
// Specify version of solidity file (https://solidity.readthedocs.io/en/v0.4.24/layout-of-source-files.html#version-pragma)
pragma solidity ^0.4.0;
contract HelloWorld {
// Define variable message of type string
string message;
// Write function to change the value of variable message
function postMessage(string value) public returns (string) {
message = value;
return message;
}
// Read function to fetch variable message
function getMessage() public view returns (string){
return message;
}
}
注:
如果需要发行TRC20代币,可参考Tron提供的合约模板。
在 Tron-IDE中编译
Tron-IDE(类似于以太坊平台上的Remix IDE )是一个用户友好的IDE,用于合约的开发。 有关使用Tron-IDE的说明,请参阅文档
如图所示,创建一个新的文件,并将Hello World智能合约源代码粘贴到文件浏览器中。 然后激活编译插件,点击编译选项卡下的 Compile Untitled.sol 按钮。

查看合约数据
在成功的编译后,您将通过单击编译选项卡下的 Compilation Details 按钮来查看Hello World智能合约数据。 详细信息包含合约名称,ABI和bytecode等。

Updated 7 months ago