Skip to content

ansmirnov/tron-deploy-trc20-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

TRON: Deploy TRC-20 token

Contents

Environment description

  • Deployed java-tron v4.0.1

Requirements

  • NodeJS 15.6.0

Install a tron-box

npm install -g tronbox

Initialize a tron-box project

tronbox init

Install openzeppelin-solidity

npm install [email protected]

Add TRC20 contract code

Contract code

pragma solidity 0.5.4;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

contract TestCoin is ERC20 {
    string public name = "Test";
    string public symbol = "TST";
    uint8 public decimals = 6;
    uint public INITIAL_SUPPLY = 10000000000000000;

    constructor() public {
	_mint(msg.sender, INITIAL_SUPPLY);
    }
}

Initial migration code

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

Contract migration code

var TestCoin = artifacts.require("./TestCoin.sol");

module.exports = function(deployer) {
  deployer.deploy(TestCoin);
};

Compile smart contracts

tronbox compile

Prepare network parameters for deployment

Write the network parameters in the .env file.

export PRIVATE_KEY="..."
export NETWORK_ID="1"
export HOST_PORT=8090

Deploy smart contracts

We use the --reset parameter to completely update the contract.

source .env && tronbox migrate --reset

Quick start in Docker

docker build -t tron-deploy-trc20 .
docker run tron-deploy-trc20 -it bash

References

  1. https://github.com/tron-us/tronbox
  2. https://developers.tron.network/docs/tron-box-user-guide
  3. https://docs.openzeppelin.com/contracts/3.x/erc20