Create TRC20 Token on TRON network with nodejs

Create TRC10 Token on TRON network with nodejs

About TRC20: https://developers.tron.network/docs/trc20

Create TRON wallet with browser extension Tronlink: https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec

Go to setting, update the environment to shasta

Get some TRX for development: https://www.trongrid.io/faucet

Prepare Token Contract: https://gist.github.com/nhancv/58997e9a6e7f896627339d122e5671bf

Note: use Remix IDE to debug easily (https://remix.ethereum.org/#optimize=true&evmVersion=null&version=soljson-v0.5.16+commit.9c3226ce.js)

To Deploy Contract 

Using tronbox

npm install -g tronbox
npm install -g tronweb
tronbox init

- Open tronbox.js -> Uncomment compiler solc version
- Create a .env file containing private key
export PRIVATE_KEY_MAINNET=4E7FECCB71207B867C495B51A9758B104B1D4422088A87F4978BE64636656243
- Update 2_deploy_contract.js file
var MyContract = artifacts.require("./NCToken.sol");
module.exports = function(deployer) {
  deployer.deploy(MyContract);
};

- To deploy: 
tronbox compile --compile-all
source .env && tronbox migrate --reset --network shasta

Using tronscan contract compiler

Access: https://shasta.tronscan.org/#/contracts/contract-compiler
Upload contract file(s) -> Select RC20Token.sol
Select Compile -> Solidity Version: tron-0.5.8_Odyssey_v3.6.0 -> Confirm
Deploy -> Accept

Register Token to Tronscan

Access https://shasta.tronscan.org/#/tokens/create/Type
Select TRC20 Token -> Yes
Fill token info same with info defined in contract
Next -> Submit -> Confirm -> Accept

View token info: https://shasta.tronscan.org/#/token20/TARCZ9Bw53DdsZ5eLYwc1GhfEkBAJsoFsv

Integrate token contract and transfer token with tronweb

Install tronweb: https://developers.tron.network/docs/tron-web-intro

npm i tronweb --save

Sample: https://gist.github.com/nhancv/7d221c6679f99154208b0643977b5d6c

Check on tronscan: https://shasta.tronscan.org/#/token20/TARCZ9Bw53DdsZ5eLYwc1GhfEkBAJsoFsv/transfers

1 thought on “Create TRC20 Token on TRON network with nodejs

  1. Hi Nhan,
    thank your post. But i’m wonder at this code `const transfer = await contractInstance.transfer(recipientAddress, amount).send(args);`

    How can i take both, transaction hash and transaction status (to know which transaction success or fail)?
    thank you

Leave a Reply

Your email address will not be published.Required fields are marked *